PDA

View Full Version : PHP: Schedule data & also grab next/previous events - radio script.



producerlawson
07-11-2015, 01:38 AM
I need a script to pull data live from my radio station's schedule.

So.. I have a jquery slider which contains 5 slides of content.

1) -2 shows ago
2) -1 shows ago
3) (0) present
4) +1 show
5) +2 shows

Now, for example at 07:00 till 09:00 on Monday it will echo the file name "oxygenbreakfast.php" - this would be placed in slide 3.

Slide 1,2,4 & 5: slide 2 needs to contain the file name for "earlyhours.php" because that was scheduled for 00:00 till 07:00 Monday

slide 1 would contain the file name for "gennation.php" because that was scheduled for 21:00 till 00:00 Sunday

slide 4 would contain the file name for "throughthemorning.php" because that was scheduled for 09:00 till 12:00 on Monday

And finally slide 5 would contain the file name "rewind.php" because that was scheduled for 12:00 till 13:00 on Monday.



Hopefully you get where I'm going with this?

Currently I have tried the following: x5 timed files for every day, for example this would be for Monday+1.php


<?php

$h = date('G', strtotime ("+1 hour")); //set variable $h to the hour of the day.
$m = date('i', strtotime ("+1 hour")); //set variable $m to the min of the hour.
$d = date('w', strtotime ("+1 hour")); //set variable $d to the day of the week.

// SATURDAY SCHEDULE
if ($d == 6 && $h >= 0 && $h < 07) $file ='earlyhours.php';
else if ($d == 6 && $h >= 07 && $h < 09) $file ='breakfast.php';
else if ($d == 6 && $h >= 09 && $h < 12) $file ='throughthemorning.php';
else if ($d == 6 && $h >= 12 && $h < 13) $file ='rewind.php';
else if ($d == 6 && $h >= 13 && $h < 17 && $m <= 30) $file ='nonstop.php';
else if ($d == 6 && $h >= 17 && $m >= 30 && $h <21) $file ='livetrend.php';
else if ($d == 6 && $h >= 17 && $m >= 35 && $h < 21) $file ='nonstop.php';
else if ($d == 6 && $h >= 21 && $h < 18) $file ='gennation.php';
else if ($d == 6 && $h >= 23) $file ='earlyhours.php';
else if ($d == 7 && $h >= 0) $file ='earlyhours.php';

require $_SERVER['DOCUMENT_ROOT'] . '/collection/profiles/' . $file . '';

?>


Then on each slide I just called the following:


$day = strtolower(date('l'));

include($day . '+1.php');


The issue with this method is that during the midnight run up and over midnight the +1,+2,-1,-2 features break because they would be trying to grab data from parts of the day that haven't happened.. when really they should be grabbing data from the previous/next days schedule if need be. Also it only adds on 1 - 2 hours, when some shows like "earlyhours.php" lasts for over 7 hours, resulting in all of the slider's slides being the same.


If you believe you can master your head around this and make it work, please quote me a price and let's work - please keep it in mind that I'm on a tight deadline and require your fastest turn round possible.

Thank you.

- James