Jump to content


Photo

IF help


  • Please log in to reply
2 replies to this topic

#1 benhodgson

benhodgson
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationLeicester, UK

Posted 24 April 2006 - 01:26 AM

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?

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 />"
;}

Many thanks in advance.

#2 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 24 April 2006 - 01:40 AM

$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>";

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

#3 benhodgson

benhodgson
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationLeicester, UK

Posted 24 April 2006 - 01:52 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users