There are two ways to do that trip, the twice a day (I think it is twice at the moment EDIT- Sam says 3 so I'm sure he's right) Thello direct train which is somewhat more expensive, or the do it yourself but less expensive multi train option.
There are three stations in Nice. The main one, and the one that the Thello calls at is Nice Ville. The local trains call at all three. Nice Riquier is closer to the old town. Nice St Augustine is close to the airport.
The DIY version is Nice via a frequent and very cheap local train to Ventimiglia, then a Regionale (very slow) or Inter City (somewhat faster) to Genova Piazza Principe and change (or possibly straight on) for Milano.
The train from Ventimiglia has the usual 3 level pricing and can be purchased while you are in Italy.
Even though the Thello is faster you may find the DIY version fits your time schedule.