Jump to content

Adding the total of one column


vollmey

Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.