Hi All,
I'm looking for a script that will function for a radio station website. I'd like it to be able to display a specific image during specific times of day. The times need to be based on server time, not the viewer's PC clock. I've found scripts that come close to what i'm looking for, but they either only display text OR they are based on the viewer's PC clock instead of server time.

Example:
From 8am - 12 Noon, display the title of the show AND the host's picture.

From 12 Noon - 3:30pm, display the title of the next show AND the host's picture.

...and so on.

The schedule will likely be the same Monday thru Friday, but Saturday and Sunday will have a different schedule.

Any help would be appreciated! :D

12-09-2006, 01:09 AM

djr33

This would best be done with PHP, or another server side code, so it can get info from a database, or at the very least, get the server's time. Javascript wouldn't be able to do as much and would be less compatible.

12-09-2006, 02:30 AM

yrrot

Hi djr33. I'm hoping for a PHP solution as well. Have you ever seen anything similar to what I'm asking for?

12-09-2006, 03:46 AM

djr33

Really, isn't all that complex.

Here's the code--

PHP Code:

<?php$h = date('G'); //set variable $h to the hour of the day//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

Very simple example, but that's the idea behind it. Depends how complex your setup if and what you want to do with it. Easy with php.

Using a database for this if you want to store all of the different things in there is a good idea, so just look into how PHP works with MySQL. Note that you need both installed on your server.
Here's a good tutorial to get you started--http://php-mysql-tutorial.com

12-10-2006, 03:50 PM

yrrot

Thanks! For some of the "if" statments, I'd like to add a check to see what the day of the week is as well. Is my modification below correct?

Code:

<?php
$h = date('G'); //set variable $h to the hour of the day
$d = date('w'); //set variable $d to the day of the week.
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

The corrections I have done were to take out the extra parenthesis "( )" (not sure on spelling). In the if - else statements you only need an opening and closing set, nothing between the && (and) or || (or). Other than that, it works. I have tested it on my home server and was able to change the times and whatnot and it works as expected.

Let me know if you need any more help.

12-10-2006, 05:14 PM

yrrot

Thanks! I'll test it out on my server and let you know if I have any trouble.

Hi Everyone,
Thanks for all your help on this one. I succesfully got this working on the new site I'm creating. I needed to display a different image for each radio host at different points throughout the day, each day of the week. I also had to include a 2 hour offset from the server's time to match my time zone. Here's what my final code looks like.

Hopfully this is helpfule to others looking to do the same thing.

Regards,
Torry

PHP Code:

<?php
$h = date('G'); //set variable $h to the hour of the day
$d = date('w'); //set variable $d to the day of the week.
$year = date('Y'); //set variable $year to the current year
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
// Adjust 2 hour offset for MST below.
$h = $h-2;