Hello Everyone,
I have a problem that I have been trying to figure out for over a month now and I would like to know if someone can get me in the right direction.
What I am doing is every month I input the vehicle monthly mileage. I have it set up to display the date of input and the mileage. I would like it to display the difference of the present input and the prevoius. Example: On 01 Jul 02 mileage was 500 and on 01 Aug 02 the mileage was 600, then the difference displayed would be 100.
How can I go about doing this???
Here's my code as it is now:
$sql = "
SELECT *
FROM mileage, lsv
WHERE mileage.vid = \"$vid\"
AND mileage.vid = lsv.vid
ORDER BY mileage.stop DESC
LIMIT 6
";
$result = @($sql,$connection) or die("Couldn't execute query.");
$the_mileage = "
<table width=375 cellpadding=2 cellspacing=2 border=0>
<tr>
<td bgcolor=#800000 width=125><font size=1 face=arial color=#ffffff>Date:</font></td>
<td bgcolor=#800000 width=125><font size=1 face=arial color=#ffffff>Odometer Reading:</font></td>
<td bgcolor=#800000 width=125><font size=1 face=arial color=#ffffff>Monthly Mileage:</font></td>
</tr>
";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$vid = $row['vid'];
$stopdate = $row['stopdate'];
$date=date('d M Y',strtotime($stopdate));
$stop = $row['stop'];
$reg = $row['reg'];
$sn = $row['sn'];
$org = $row['org'];
$vco_n = $row['vco_n'];
$vco_e = $row['vco_e'];
$the_mileage .= "<tr>
<td bgcolor=#808080 width=125><font size=1 face=arial>$date</font></td>
<td bgcolor=#808080 width=125><font size=1 face=arial>$stop</font></td>
<td bgcolor=#808080 width=125><font size=1 face=arial></font></td>
";
}
$the_mileage .= "</tr></table>";
Any help would be gratefully appreciated.
:o) Ivan