To place the mileage in the title tag place this in the middle of it:
<?php echo $miles; ?>
You may have to work without output buffering so that everything executes/parses before writting out. Will have to see.
<?php
$host = "localhost";
$user = "username";
$pass = "password";
$dbase = "coasters";
$dbcnx = @mysql_connect($host,$user,$pass);
if (!$dbcnx) {
die('unable to connect to database server at this time.<p>');
}
if (! @mysql_select_db("$dbase") ) {
die('unable to connect to db at this time.<p>');
}
$result = @('SELECT * FROM trackrecord ORDER BY name');
if (!$result) {
die ('Error performing query: ' . mysql_error() . '<p>');
}
if (mysql_num_rows($result) < 1) {
echo ("No records available");
} else {
// create table and add first row with headers.
echo ('<table align=center width=60% border=0');
echo ('<tr align=center>
<td><font face="Verdana" size="4"><strong><u>Name </u></strong></font></td>
<td><font face="Verdana" size="4"><strong><u>Type </u></strong></font></td>
<td><font face="Verdana" size="4"><strong><u>Park </u></strong></font></td>
<td align=right><font face="Verdana" size="4"><strong><u>Length (ft) </u></strong></font></td>
</tr>');
// we create a var with a zero value
$Clen = 0;
// this is the data output from the table.
while ($row = mysql_fetch_array($result) ) {
echo ('<tr>');
echo ('<td><font face="Verdana" size="3">' . $row['name'] . '</td><td><font face="Verdana" size="3">' . $row['type'] . '</td><td><font face="Verdana" size="3">' . $row['park'] . '</td><td align=right><font face="Verdana" size="3">' . $row['length'] . '</td></tr></b>');
// we take the existing $Clen and add the lenghth of the latest pulled row[length] to it
$Clen = ($Clen + $row['length']);
}
// END of data extraction, close table.
echo ('</tr></table>');
echo ("<p>");
// Now we echo back the total of all the lengths added together
echo $Clen;
// Now we echo back the $Clen divded by footage
$miles = ($Clen / 5279.8556430);
echo $miles;
}
?>