billypilgrim32
asked on
modify on-air now php script
I'm looking for a php script that will display an on-air schedule for a radio station I work for. Ray_Paseur did the heavy lifting and wrote the following code that accurately switches my images based on what time it is, but I also need to display:
a) the title of the show (as a hyperlink),
b) the time the show begins and ends,
c) the following show (as a hyperlink).
Plus, this script needs to include the entire week (weekend programs and weekday programs are different).
Here's Ray_Paseur's script, which masterfully rotates my images based on the time of day:
Thanks!
a) the title of the show (as a hyperlink),
b) the time the show begins and ends,
c) the following show (as a hyperlink).
Plus, this script needs to include the entire week (weekend programs and weekday programs are different).
Here's Ray_Paseur's script, which masterfully rotates my images based on the time of day:
<?php // RAY_temp_billypilgrim32.php
error_reporting(E_ALL);
// SET THE CORRECT TIMEZONE
date_default_timezone_set('America/Chicago');
// A FUNCTION TO RETURN THE IMAGE URL BASED ON A GIVEN TIME
function imageUrl($hhmm='now')
{
// DEFINE A PROGRAM CLASS
if (!class_exists('Program'))
{
Class Program
{
public function __construct
( $a // START TIME
, $z // END TIME
, $i // IMAGE URL
			, $t // Show Title
)
{
$this->a = $a;
$this->z = $z;
$this->i = $i;
}
}
}
// MAKE AN ARRAY OF PROGRAM OBJECTS
$programs = array
( new Program('0000', '0200', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host1.jpg')
, new Program('0200', '0400', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/shows/radionews.gif')
, new Program('0400', '0600', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host2.jpg')
, new Program('0600', '0800', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host3.jpg')
, new Program('0800', '1000', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host4.jpg')
, new Program('1000', '1200', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host5.jpg')
, new Program('1200', '1400', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host6.jpg')
, new Program('1400', '1600', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host1.jpg')
, new Program('1600', '1800', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host7.jpg')
, new Program('1800', '2000', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host8.jpg')
, new Program('2000', '2200', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host9.jpg')
, new Program('2200', '2400', 'http://www.scotthennen.com/wp-content/themes/shs/schedule/host10.jpg')
)
;
// NORMALIZE THE DATETIME STRING
$hhmm = date('hi', strtotime($hhmm));
// DETERMINE THE IMAGE NEEDED
foreach ($programs as $timeslot)
{
if ($hhmm >= $timeslot->a)
{
if ($hhmm <= $timeslot->z)
{
$url = $timeslot->i;
}
}
}
// CREATE THE IMAGE TAG
$tag = <<<TAG
<img alt="Host Image" title="$hhmm" src="$url" />
TAG;
return $tag;
}
// TEST THE FUNCTION
echo '<br clear="all" />' . imageurl();
echo '<br clear="all" />' . imageurl('now+37 minutes');
echo '<br clear="all" />' . imageurl('now+237 minutes');
?>
Thanks!
ASKER
Appreciate all your hard work Ray---the challenge for me is to somehow deconstruct this brilliant piece of coding. I'm just an HTML guy, so all of this looks like Mandarin Chinese to me.
I'll look at this again. If it still looks chinese to you, then you really should consider hiring a professional developer to help you with it. Nothing you want is "hard" but it is time-consuming and a developer should be paid for the time it will take to do all you need to have done. If this does not have any economic value and you're just using it as a learning tool, then consider getting this excellent little book and give yourself a few weeks to work through the examples. It will not make you a pro, but it will give you some foundation in how PHP and MySQL work together.
http://www.sitepoint.com/books/phpmysql4/
http://www.sitepoint.com/books/phpmysql4/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've requested that this question be deleted for the following reason:
Not enough information to confirm an answer.
Not enough information to confirm an answer.
Recommend accept this. It has a tested and working code sample that shows exactly how to solve the problem:
https://www.experts-exchange.com/questions/27634413/modify-on-air-now-php-script.html?anchorAnswerId=37769179#a37769179
https://www.experts-exchange.com/questions/27634413/modify-on-air-now-php-script.html?anchorAnswerId=37769179#a37769179
I am going to bed now, and I will look at it again in the morning. However there are many wise and clever developers here at EE who may be able to get a quick answer overnight.
Best regards, ~Ray