View Single Post
  #5 (permalink)  
Old 09-08-2004, 07:18 AM
Jason Jason is offline
GreenHybrid Founder
 
Real Name: Jason Siegel
Location: Houston, TX
Hybrids: 2004 Toyota Prius
Posts: 4,487
Default

Andy,
Please stop trying to undermine the database. It is a computer. It doesn't have a mind of its own.

Gallons are not stored in the database. You cannot calculate gallons and then use gallons to calculate something else. That is completely unscientific and inexact.

An individual tank's gallons will be less accurate than the overall car because there is less data. That's simply all there is to it.

Here is the actual code in the databsae. It's PHP, a serverside language. Enjoy.

Weighting total mileage (loops):

Quote:
while ( $weight = mysql_fetch_array($weightresult) ) {

$mileagenumerator = $mileagenumerator + $weight['mileage']*$weight['distance'];

$denominator = $denominator + $weight['distance'];

$mileage = $mileagenumerator/$denominator;
}
Calculating total gallons:
Quote:
echo number_format(1/$car1['avgmileage']*$car2['sumdistance'],1);
Calculating tank gallons:
Quote:
echo round(1/$data['mileage']*$data['distance'],1);

.

Visit my newly-acquired website, Volconvo Debate Forums!


Reply With Quote