Forum Moderators: coopster
I'm completely new to PHP and so far its been a bit of a bumpy ride. I am currently trying to produce a script that will display a timetable, and highlight the flights within the next hour in bold ($isBold). I have gone as far as i can but cant find any reference material.
Here is the script I have come up with, and I have included a basic outline of what I want to do, but I am struggling to find the correct syntax for it. Any help would be hugely appreciated.
Kind Regards
Mambo
<?php
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("airline", $con);
$result = mysql_query("SELECT * FROM flights ORDER BY DepartureTime");
print time();
$currtime = time();
$isBold=0
if( $currtime <= $row['DepartureTime'] AND $currtime+60*60*1000 > $row['DepartureTime'])
echo $isBold[$mesiac[0]-1];
$isBold=1
else
write Flight Details
if ($IsBold==1) write close Bold
echo "<table border='1'>
<tr>
<th>Flight Number</th>
<th>Departing</th>
<th>Arriving</th>
<th>Departure Time</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FlightNumber'] . "</td>";
echo "<td>" . $row['DepartingFrom'] . "</td>";
echo "<td>" . $row['ArrivalAt'] . "</td>";
echo "<td>" . $row['DepartureTime'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Remove your bold stuff, then figure it out inside the while - I've simplified your math a little, and time() doesn't go to milliseconds so the 1000 is out:
while($row = mysql_fetch_array($result))
{
$leaving = $row['DepartureTime'] - $currtime;
if(($leaving > 0) && ($leaving <= 3600))
$class = 'highlight';
else
$class = '';
echo "<tr class=\"$class\"";