Airstaff rotator for website

Ok, so this has nothing to do with mAirList ;D , but I was wondering if some of you who are immensly smarter than I with php could give me some help.

I have a website that I’m developing for a station I work for. I’m using Joomla! (joomla.org) as the content system, have a module rotator set-up so that from midnight-4am a certain pic is displayed, etc. etc. (see screenshot 1 for the code, ss 2 for what it displays on the page)

BUT- I need this to change based on the day of the week. Is there a way to do this in php?

For instance- Mon-Fri have one set and Sat have another and Sun have another?

Thanks for any help you can give me!
Matt


1.JPG

2.JPG

Hi lilmatt, not sure how to do this with php as there are few examples when using google.

At a guess you need to declare a getday function at the start of the script and then a statement for each day chosing which picture to load.

You should also be able to incorporate a gettime function to allow different images throughout each day.

The actual code though is beyond me, I achieve a random image using an ifame script from www.dynamicdrive.com, perhaps Charlie can help with the php.

I’ll have another search later.

Kind regards Tony

[quote=“lilmatt, post:1, topic:5750”]BUT- I need this to change based on the day of the week. Is there a way to do this in php?
For instance- Mon-Fri have one set and Sat have another and Sun have another?[/quote]Ok, take a look at this - some of the entries include an image and a link, so have a play around but it should all be self-explanatory as it’s well commented.

EDIT: Much better (and working) code now here:

[code]

<?php $today = getdate(); // Schedule System // by Charlie Davy, November 2008 // Monday if($today['wday'] == 1){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('Monday Daytime'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('An Hour of Stuff'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('Drivetime'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('The Evening Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('The Late Bit'); } } // Tuesday elseif($today['wday'] == 2){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('Tuesday Daytime'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('An Hour of Stuff'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('Drivetime'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('The Evening Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('The Late Bit'); } } // Wednesday elseif($today['wday'] == 3){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('

Wednesday Daytime

'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('An Hour of Stuff'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('Drivetime'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('The Evening Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('The Late Bit'); } } // Thursday elseif($today['wday'] == 4){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('Thursday Daytime'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('An Hour of Stuff'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('

Drivetime'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('The Evening Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('

The Late Bit

'); } } // Friday elseif($today['wday'] == 5){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('Friday Daytime'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('An Hour of Stuff'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('Drivetime'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('

Classics

'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('

Beats'); } } // Saturday elseif($today['wday'] == 6){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('The Charlie Show'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('The Weekend Alternative'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('Classics'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('LP - The Album Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo(' Beats'); } } // Sunday elseif($today['wday'] == 0){ if (($today['hours'] >= 0 && $today['hours'] <=6) ){ echo('My Radio'); } elseif (($today['hours'] >= 6 && $today['hours'] <= 9) ){ echo('Breakfast'); } elseif (($today['hours'] >= 9 && $today['hours'] <= 14) ){ echo('The Charlie Show'); } elseif (($today['hours'] >= 15 && $today['hours'] <= 16) ){ echo('The Weekend Alternative'); } elseif (($today['hours'] >= 16 && $today['hours'] <= 19) ){ echo('The Last FM Chart'); } elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('The Evening Show'); } elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('The Late Bit'); } } // Any other day not included in the week ? else { } ?>

[/code]

There’s also a final “else” at the end should they bring in Sunday2 to help the younger generation recover from their Saturday night binge sessions.

Hi Charlie, any more pointers on this.

I have made a php page from the exact code and uploaded to a site with php enabled.

It just returns a blank page.

Kind regards tony

You’re right - it does! Looks like Wednesday has 2 instead of 3 for the day - so the code cannot “see” a Wednesday definition. Change Wednesday from a 2 to a 3 and it’ll work.

As this runs on your web server, it retrieves the time from there and NOT the user’s computer (which may be helpful if you have lots of foreign listeners - and not so if you’re hosted in the US!). Offsetting the time is quite simple, btw.

See it in action here: http://www.charliedavy.co.uk/onair.php

Cheers Charlie.

Sorry for the late reply…

IT WORKED LIKE A CHARM!!! Thanks sooo much, it’s exactly what I was looking for, one thing though

I assume (but you know what they say about that ;D) that if i wanted a show to start at 5:50 am, I would change the start value to 5:50, but this returns an error. Would I instead have to make it 05:50:00?

-Matt

Sure, you just add a minutes statement into it :wink:

[code]} elseif (($today[‘hours’] >= 11 && $today[‘minutes’] <= 30 && $today[‘hours’] <= 14) ){ echo(‘It is before 11:30am’);

} elseif (($today[‘hours’] >= 11 && $today[‘minutes’] >= 30 && $today[‘hours’] <= 14) ){ echo(‘It is after 11:30am’);[/code]

There’s a “before and after half-past” to give you an idea of how to do it. The first line is 11:00am-11:30am, the 2nd is 11:31am-2:00pm… Simple innit!