Hey Friendly Peoples,
I Started work at a radio station a few months back and I have been renovating our website. One of my projects is to improve the script that controls a sidebar widget that shows which dj is on air. I would like to find a better way to make this work. Maybe have it run from a database so it can be edited easier. I really haven't dealt with time and date stuff much so I wanted to get some suggestions or ideas on how to go about improving this script. I would like to see about how you guys might go about solving this issue. I have set and brain stormed out some possibilities but I just cant seem to make it work out. My vision for how I would like it to work is kinda like this. Each dj in the database would have the days he is on air and the times that day he is on air. Then I would have a class that takes the current day and time and finds a dj that matches. I can pretty much build the database but I am kinda at a loss as to how I would match the day and time to a dj and how I could protect djs from overlapping. This is What is currently running the widget.
<?php
//set timezone
putenv ('TZ=America/Chicago');
mktime(0,0,0,1,1,1970);
$day = date("N");
$time = date("Hi");
if ($day == 7)
{
switch($time)
{
case ($time >= '0600' && $time <= '0959'):
echo"<img src='images/onair/haroldgrimmett.png' alt='Harold Grimmett is On-Air Now' class='onair'/>";
break;
case ($time >= '1000' && $time <= '1200'):
echo"<img src='images/onair/kix103.png' alt='Harold Grimmett is On-Air Now' class='onair'/>";
break;
default:
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
break;
}
}
elseif($day == 6)
{
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
}
else
{
switch($time)
{
case ($time >= '0600' && $time <= '0959'):
echo"<img src='images/onair/steveandboomer.png' alt='Steve & Boomer is On-Air Now' class='onair'/>";
break;
case ($time >= '1000' && $time <= '1459'):
echo"<img src='images/onair/kc.png' alt='K.C. Wright is On-Air Now' class='onair'/>";
break;
case ($time >= '1500' && $time <= '1859'):
echo"<img src='images/onair/jr.png' alt='J.R. Schumann' class='onair'/>";
break;
case ($time >= '1900' && $time <= '2359'):
echo"<img src='images/onair/jrandalharvey.png' alt='J Randal Harvey is On-Air Now' class='onair'/>";
break;
case ($time >= '2400' && $time <= '0559'):
echo"<img src='images/onair/blairgarner.png' alt='Blair Garner is On-Air Now' class='onair'/>";
default:
echo"<img src='images/onair/kix103.png' alt='Kix 103 the Country Leader is On-Air Now' class='onair'/>";
break;
}
}
?>
You can see it in action on www.kix1033.com
Thanks for your time and suggestions.
Vale