If you are just trying to calculate gas mileage heres how to do it:
1. Fill up tank.
2. Drive some amount of miles, it doesn't matter, but i'd try to use a couple of gallons of gas and do your normal type of driving, perhaps a mix of city and highway.
3. Fill up tank again. Make note of how many miles you just drove and how many gallons you filled up with.
4. Divide amount of miles driven by gallons used since last fill up. For example, say you drove 60 miles and the second time you filled up it took 2 gallons that gives you an avg mileage of 30mpg.
I don't know if this is exactly what you are after but this is the best way I know of to calculate actual fuel economy. You should be able to then take these numbers and figure out the cost/mile.
If you are trying to figure out cost/mile including all costs (insurance, gas, tires, repairs, maintenance, interest, etc it would be best I would think to do this on a yearly basis. You'd have to take all of your costs associated with driving that car for a specific period of time and divide that number by the amount of miles driven. I would think a quarterly or yearly basis would be good since insurance, car payments, etc are paid in amounts that are easy to figure out the yearly cost of.