Sorry, me again. Is it possible to help me with being able to sort by clicking on column headers. And the code again:
$query = "SELECT firstname, lastname, pilotid1, pilotid2, COUNT(flight_time) AS flights, SUM(block_time) AS block, SUM(flight_time) AS ftime, MAX(date_of_flight) AS date FROM members, pireps WHERE members.pilotid1 = pireps.pilotid2 GROUP BY pilotid1 ORDER BY flights DESC, block DESC, ftime DESC, date DESC";
$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>First</th> <th>Last</th> <th>Pilot ID</th> <th>Flights</th> <th>Block Time</th> <th>Flight Time</th> <th>Rank</th> <th>Currently In</th> <th>Last Flight</th></tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr><td align=left>";
echo $row['firstname'];
echo "</td><td align=left>";
echo $row['lastname'];
echo "</td><td align=center>";
echo $row['pilotid1'];
echo "</td><td align=center>";
echo $row['flights'];
echo "</td><td align=center>";
echo sprintf( "%4.1f", $row['block'] );
echo "</td><td align=center>";
echo sprintf( "%4.1f", $row['ftime'] );
echo "</td><td align=center>";
$var1 = '<img src="pics/rankings/fo.gif">';
$var2 = '<img src="pics/rankings/sfo.gif">';
$var3 = '<img src="pics/rankings/c.gif">';
$var4 = '<img src="pics/rankings/sc.gif">';
$var5 = '<img src="pics/rankings/jfo.gif">';
if($row['block']>1299.9 && $row['flights']>519){
echo $var4;
}elseif($row['block']>799.9 && $row['flights']>319){
echo $var3;
}elseif($row['block']>399.9 && $row['flights']>159){
echo $var2;
}elseif($row['block']>99.9 && $row['flights']>39){
echo $var1;
}elseif($row['block']>0){
echo $var5;
}
echo $row['rank'];
echo "</td><td align=center>";
$arrival = mysql_query("Select arr_airport from pireps where pilotid2 = '".$row['pilotid1']."' order by date_of_flight DESC LIMIT 0,1") or die(mysql_error());
while($arrive = mysql_fetch_array($arrival)){
echo $arrive['arr_airport'];
}
echo "</td><td align=center>";
echo $row['date'];
echo "</td></tr>";
}
echo "</table>";
?>