Hi Everyone,
I thought I had everything going right until we had a dip@#!% here at work challenge us. He went in and did not put in his monthly mileage in cronological order it's all mixed. The statement I have orders them by the last inputted stop mileage and when I try to change it to the stopdate it will not display my $diff correctly. They show up as "0".
Can someone take a look and see what can be done, PLEASE. It's been a fustrating week.
Thanks for all help.
:o) Ivan
CODE:
$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>
<style>table{ font-family : Arial; font-size : 12px; } .evenrow { background-color : #808080;} .oddrow { background-color : #C0C0C0;}</style>
";
$oldMiles = 0;
$evenrow = false;
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'];
$diff = $oldMiles - $stop;
if ($diff < "0") {
echo "0";
}
else {
echo "$diff";
}
$the_mileage .="
<tr class='" . (evenrow ? "evenrow" : "oddrow") . "'>
<td width=125>$date</td>
<td width=125>$stop</td>
<td width=125>$diff</td>
";
$oldMiles = $stop;
$evenrow = !$evenrow;
}
$the_mileage .= "</tr></table>";