vollmey Posted May 8, 2006 Share Posted May 8, 2006 I really hate to ask I basic question to alot of you guys, but I just can't figure it out. On my website [a href=\"http://www.davevollmer.com\" target=\"_blank\"]www.davevollmer.com[/a] I would like to add the Block Time column and display the figure as "Total Time" in a box centered right above the table.Here is what I have now[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] // Execute SQL query $query = "SELECT IDPIREP, CreatedOn, IDPilot, PilotName, Airline, FlightNumber, OriginAirport, DestinationAirport, BlockTime, DistanceFlight, FlightFuel FROM pirep ORDER BY CreatedON DESC"; $result = mysql_query($query) or die("SQL query failed."); if (mysql_num_rows($result) == 0) die("There are currently no PIREPs available.");?><html><head><meta http-equiv="Content-Language" content="en-us"><title>FS Flight Keeper - Dave Vollmer.com Flights</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Expires" content="0"><style type="text/css"><!--tr { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px;}--></style></head><body><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Davevollmer.com Flights</strong></font><br><br><table width="680" border="0" cellpadding="4" cellspacing="0" bordercolor="#FFFFFF"> <tr bordercolor="#FFFFFF" bgcolor="#00CCFF"> <td width="80"><font color="#333333"><strong>Filed On</strong></font></td> <td width="110"><font color="#333333"><strong>Flight</strong></font></td> <td width="180"><font color="#333333"><strong>Pilot</strong></font></td> <td width="352"><font color="#333333"><strong>From - To </strong></font></td> <td width="55"><div align="center"><font color="#333333"><strong>Block Time</strong></font></div></td> <td width="111"><div align="center"><font color="#333333"><strong>Distance NM</strong></font></div></td> <td width="80"><div align="center"><font color="#333333"><strong>Flight Fuel (lbs) </strong></font></div></td> </tr> <?php $i = 0; while ($row = mysql_fetch_object($result)) { ?> <?php if (fmod($i, 2) == 0) { print "<tr bordercolor=\"#FFFFFF\" bgcolor=\"#FFFFCC\">"; } else { print "<tr bordercolor=\"#FFFFFF\" bgcolor=\"#FFCC99\">"; } ?> <td><?php print date("m.d.Y", convert_timestamp($row->CreatedOn)); ?></td> <td><a href="PIREPDetails.php?ID=<?php print $row->IDPIREP; ?>" target="PIREP_DETAILS"><?php print $row->Airline." ".$row->FlightNumber; ?></a></td> <td><?php print $row->PilotName." (".$row->IDPilot.")"; ?></td> <td> <?php /* ### Changed v2.6 ### */ print $row->OriginAirport; if (strlen($row->DestinationAirport) != 0) print " <b>-></b> ".$row->DestinationAirport; ?> </td> <td><div align="center"><?php print $row->BlockTime; ?></div></td> <td><div align="center"><?php print $row->DistanceFlight; ?></div></td> <td><div align="center"><?php print number_format($row->FlightFuel, 0, ",", "."); ?></div></td> </tr> <?php $i = $i + 1; } ?> </table></font></body></html><?php?>[/quote]It's proably very, very, very basic but any help would be greatly appreciated.Thanks!!Dave Vollmer Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2006 Share Posted May 8, 2006 What field type is the Blocktime field? And what kind of data does it hold? If it where just numbers it would be a simple...[code]SELECT SUM(Blocktime) AS totaltime FROM tbl;[/code]But it sounds to me like you have some sort of timestamp in this field. Quote Link to comment Share on other sites More sharing options...
vollmey Posted May 8, 2006 Author Share Posted May 8, 2006 Ok, once again I'm going to show my Newb status. Type of field = Varchar and yes it just hold numbers. Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2006 Share Posted May 8, 2006 Well, VARCHAR is of absolutley no use here. You cant sum up strings. If you can, change the field to some sort of numeric type eg INT. Then you can simply follow my example above. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.