Hi,
I've been trying to work out what the hell is wrong with the code, but I can't find anything. I've changed the id values to 0 and others and all results are as to be expected. The actual code works fine and I get everyone's correct id number, all except for id 10. 10 always returns as 9 eventhough it is 10 the the DB. MySQL DB.
/* Select all pilots */
$query = "SELECT * FROM reports ORDER BY report_id DESC limit 50";
$result = mysql_query($query);
/* Determine the number of pilots */
$number = mysql_numrows($result);
if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table align=center>";
print "<tr>";
print "<td class=FSACARS3>ID</td>";
print "<td class=FSACARS3>PILOT ID</td>";
print "<td class=FSACARS3>DATE</td>";
print "<td class=FSACARS3>CALLSIGN</td>";
print "<td class=FSACARS3>FROM</b></td>";
print "<td class=FSACARS3>TO</td>";
print "<td class=FSACARS3>REG</td>";
print "<td class=FSACARS3>EQUIPMENT</td>";
print "<td class=FSACARS3>DURATION</td>";
print "<td class=FSACARS3>FUEL</td>";
print "<td class=FSACARS3>DISTANCE</td>";
print "<td class=FSACARS3>DETAILS</td>";
print "</tr>";
/* Get report info */
for ($i=0; $i<$number; $i++) {
$ireport = mysql_result($result,$i,"report_id");
$id = mysql_result($result,$i,"id");
$date = mysql_result($result,$i,"date");
$time = mysql_result($result,$i,"time");
$fsacars = mysql_result($result,$i,"fsacars_rep_url");
$report = mysql_result($result,$i,"report_id");
$callsign = mysql_result($result,$i,"callsign");
$origin = mysql_result($result,$i,"origin_id");
$destination = mysql_result($result,$i,"destination_id");
$registration = mysql_result($result,$i,"registration");
$equipment = mysql_result($result,$i,"equipment");
$duration = mysql_result($result,$i,"duration");
$fuel = mysql_result($result,$i,"fuel");
$distance = mysql_result($result,$i,"distance");
$id = $id-1;
// $id = $id-1;
/* Calculate flight hours */
$query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM pilots t1, reports t2 WHERE t1.id=$id AND t1.id=t2.id";
$result_hours = mysql_query($query_hours);
if (mysql_numrows($result_hours) > 0) {
$time = mysql_result($result_hours,0,"duration_sum");
}
?>
I have also tested to see if it would happen on 100, and guess what? 100 showed as 100.
I am lost for this one. Can anyone see what is wrong or why this is happening?
Cheers
Steph.