Hi, I am currently building a site for a radio website. On the main page I want there to be a line of text saying which is show is currently on air. I have set up a database with the full schedule which consists of a number of different shows throughout the day.
My database fields are:
id
showname
showdetails
day
timestart (time, set as start time of a particular show)
timeend (time, set as end time of a particular show)
showdate (date, default 0000-00-00)
this is what I have so far.. it shows the current time, but does not show what show corresponds to the current time:
$hour = date('H');
$minutes = date('i');
$newtime = "$hour:$minutes";
$day = date('D');
echo $newtime; // I used these to make sure i was getting the right time.
echo "<br><Br>";
echo $day; // again, another debug line for the right day.
$link = mysql_connect('localhost', 'username', 'password');
mysql_select_db("my_databasename", $link);
$query = "SELECT * FROM schedule WHERE showdate = '".$day."' AND 'timestart' <= '".$newtime."' ORDER BY 'timeend' ASC";
$result = mysql_query($query, $link) or die(mysql_error());
$row=mysql_num_rows($result);
for ($j = 0 ; $j < $row ; ++$j)
{
echo '<br/>';
echo '<b>' . mysql_result($result,$j,'showname') . ' - ' . mysql_result($result,$j,'timestart') .'</b><br/>';
echo '' . mysql_result($result,$j,'timeend') . '<br/><br/>';
}
mysql_close($Link);
Would really appreciate some help with this. Many thanks.