Help please,
been working on this one week too long, This is my complete script, sorry its kinda long, my problem is down at the bottom, i want to show total hours, but cant seam to get it right.
If you notice, the script is creating a table with alternating colors, i dont mind if my total hours at the bottom is all by itself, just help me show it.
<?PHP
$db = mysql_connect("localhost","xxxx","xxxx") or die("Problem connecting");
mysql_select_db("xxxxx") or die("Problem selecting database");
$query = "SELECT FROM pirep2 ORDER BY id";
if ($pilotid == "")
{$pilotid = '%';}
$result = mysql_query ("SELECT FROM pirep WHERE pilotid LIKE '$pilotid%'");
$numofrows = mysql_num_rows($result);
include ("header.php");
?>
<?PHP
print "<center><center>";
print "<TR>\n<TD><b>Your Logbook</b></TD>\n";
print "<hr>";
echo "<TABLE BORDER=\"1\">\n";
echo "<TR bgcolor=\"#FFFF9F\"><td align=\"center\"><font face=Arial size=1> Pilot ID </TD><td
align=\"center\"><font face=Arial size=1> Departure </TD><td align=\"center\"><font face=Arial size=1>
Destination </TD><td align=\"center\"><font face=Arial size=1> Hours </TD><td align=\"center\"><font
face=Arial size=1> Route </TD><td align=\"center\"><font face=Arial size=1> Feul Used </TD><td
align=\"center\"><font face=Arial size=1> Date </TD><td align=\"center\"><font face=Arial size=1> Comments
</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"lightblue\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#D2FFE9\">\n";
}
echo "<td align=\"center\"><font face=Arial size=1>".$row['pilotid']."</TD><td align=\"center\"><font face=Arial
size=1>".$row['departure']."</TD><td align=\"center\"><font face=Arial size=1>".$row['destination']."</TD><td
align=\"center\"><font face=Arial size=1>".$row['hours']."</TD><td align=\"center\"><font face=Arial
size=1>".$row['route']."</TD><td align=\"center\"><font face=Arial size=1>".$row['feul']."</TD><td align=\"center\"><font
face=Arial size=1>".$row['date']."</TD><td align=\"center\"><font face=Arial size=1>".$row['comments']."</TD>\n";
echo "</TR>\n";
}
/////////////////////////////////////////////////////////////PROBLEM////////
$sql2 = " SELECT SUM(hours) AS total,
FROM pirep
WHERE pilotid = '$pilotid'
";
$result2 = mysql_query($sql2);
while ($row2 = mysql_fetch_array($result2)) {
$hours = $row2["hours"];
//////////////////////////////////////////////////////////////////////////////
include ("footer.php");
echo "</TABLE>\n";
?>
I know its not pretty, but after two weeks its all i can come up with.....?????
any help sure would be appreciated!