Jump to content

Archived

This topic is now archived and is closed to further replies.

benhodgson

IF help

Recommended Posts

I'm currently writing a schedule system for a radio station.

Basically the schedule page will look a little like this [a href=\"http://www.zodiacwebdesign.co.uk/sites/demonfm/\" target=\"_blank\"]http://www.zodiacwebdesign.co.uk/sites/demonfm/[/a]

Now what I want to do is have the system check the current time using $nowtime = date("Hi"); and $nowday = date("D"); and compare it with the entries in the database $day, $starttime and $endtime. If a show is today and nowtime is between $starttime and $endtime, meaning the show is on air at the moment, then I want the show to appear in a different font colour.

As you can see from the site I'm having some difficulty and my code is now a little messed up. Is there anyone out there who can give me a hand and make this work?

[code]if (what goes here?)
{
echo "<span class=\"main\"><strong>$start - $end</strong> $name</span><br />";}
else
{
echo "<span class=\"nowshow\"><strong>$start - $end</strong> $name</span><br />"
;}[/code]

Many thanks in advance.

Share this post


Link to post
Share on other sites
[code]
$nowtime = date("Hi"); //Getting time
$nowday = date("D"); //Getting day

$query = mysql_query("SELECT * FROM show WHERE day like '$nowday'") or die(mysql_error());//Getting all data from the table where the show is to day
$query_rows = mysql_num_rows($query); //Seeing if there is any

if($query_rows > 0)//if more than 0 then there is atleast 1 show today
{
     while($shows = mysql_fetch_array($query)) // putting into an array
      {
          $start = $shows['start'];
          $end = $shows['end'];
      }
      
     if(($nowtime =< $end) && ($nowtime >= $start)) //checking if the time is inbetween show times
     {
             echo "<font color=#FF0000>Show</font>";
     } else echo "<font color=#000000>Show</font>";
}echo "<font color=#000000>Show</font>";
[/code]

Something I threw together, I hope thats what you want.

Share this post


Link to post
Share on other sites
Only needed the actual part to go in the IF section, but fantastic, have it working now. Thanks for your help :)

Share this post


Link to post
Share on other sites

×

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.