Tricky Php Timecode Issue for Radio Site

Hey all. This could be a long, but rewarding riddle to crack for you coders out there. I’m willing to offer whoever cracks it £20 ($31 or €23) which I’ll transfer via paypal upon completion.

I’m currently making a site for my University’s radio station and I’m doing it by using some advanced wordpress techniques and modding the hell out of plugins. Just to let you know now, I’m not a computer science student, but I have good self learned knowledge of html/css, but my php is a little sketchy.

Therefore, I’ve got a bit stuck on one particular feature. I am required to make an ‘On Air Now’ tab which displays the name and image of the show that is currently on air.

At the moment, I have the following code working well:

[php]<?php
date_default_timezone_set(‘Europe/London’);
$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.
//Enter show details for each hour within the parses.

// MON SCHEDULE
if ($d == 1 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 1 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 1 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 1 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 1 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 1 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 1 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 1 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 1 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 1 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 1 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 1 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 1 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 1 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 1 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 1 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 1 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 1 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 1 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 1 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 1 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 1 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 1 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 1 && $h >= 23 && $h < 0) { $showname = ’ '; }

// TUES SCHEDULE
if ($d == 2 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 2 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 2 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 2 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 2 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 2 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 2 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 2 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 2 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 2 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 2 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 2 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 2 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 2 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 2 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 2 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 2 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 2 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 2 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 2 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 2 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 2 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 2 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 2 && $h >= 23 && $h < 0) { $showname = ’ '; }

// WEDS SCHEDULE
if ($d == 3 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 3 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 3 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 3 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 3 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 3 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 3 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 3 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 3 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 3 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 3 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 3 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 3 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 3 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 3 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 3 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 3 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 3 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 3 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 3 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 3 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 3 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 3 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 3 && $h >= 23 && $h < 0) { $showname = ’ '; }

// THURS SCHEDULE
if ($d == 4 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 4 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 4 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 4 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 4 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 4 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 4 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 4 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 4 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 4 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 4 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 4 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 4 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 4 && $h >= 13 && $h < 14) { $showname = ‘Test’; }
else if ($d == 4 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 4 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 4 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 4 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 4 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 4 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 4 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 4 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 4 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 4 && $h >= 23 && $h < 0) { $showname = ’ '; }

// FRI SCHEDULE
if ($d == 5 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 5 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 5 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 5 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 5 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 5 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 5 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 5 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 5 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 5 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 5 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 5 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 5 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 5 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 5 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 5 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 5 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 5 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 5 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 5 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 5 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 5 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 5 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 5 && $h >= 23 && $h < 0) { $showname = ’ '; }

// SAT SCHEDULE
if ($d == 6 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 6 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 6 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 6 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 6 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 6 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 6 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 6 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 6 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 6 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 6 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 6 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 6 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 6 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 6 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 6 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 6 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 6 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 6 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 6 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 6 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 6 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 6 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 6 && $h >= 23 && $h < 0) { $showname = ’ '; }

// SUN SCHEDULE
if ($d == 0 && $h >= 0 && $h < 1) { $showname = ’ '; }
else if ($d == 0 && $h >= 1 && $h < 2) { $showname = ’ '; }
else if ($d == 0 && $h >= 2 && $h < 3) { $showname = ’ '; }
else if ($d == 0 && $h >= 3 && $h < 4) { $showname = ’ '; }
else if ($d == 0 && $h >= 4 && $h < 5) { $showname = ’ '; }
else if ($d == 0 && $h >= 5 && $h < 6) { $showname = ’ '; }
else if ($d == 0 && $h >= 6 && $h < 7) { $showname = ’ '; }
else if ($d == 0 && $h >= 7 && $h < 8) { $showname = ’ '; }
else if ($d == 0 && $h >= 8 && $h < 9) { $showname = ’ '; }
else if ($d == 0 && $h >= 9 && $h < 10) { $showname = ’ '; }
else if ($d == 0 && $h >= 10 && $h < 11) { $showname = ’ '; }
else if ($d == 0 && $h >= 11 && $h < 12) { $showname = ’ '; }
else if ($d == 0 && $h >= 12 && $h < 13) { $showname = ’ '; }
else if ($d == 0 && $h >= 13 && $h < 14) { $showname = ’ '; }
else if ($d == 0 && $h >= 14 && $h < 15) { $showname = ’ '; }
else if ($d == 0 && $h >= 15 && $h < 16) { $showname = ’ '; }
else if ($d == 0 && $h >= 16 && $h < 17) { $showname = ’ '; }
else if ($d == 0 && $h >= 17 && $h < 18) { $showname = ’ '; }
else if ($d == 0 && $h >= 18 && $h < 19) { $showname = ’ '; }
else if ($d == 0 && $h >= 19 && $h < 20) { $showname = ’ '; }
else if ($d == 0 && $h >= 20 && $h < 21) { $showname = ’ '; }
else if ($d == 0 && $h >= 21 && $h < 22) { $showname = ’ '; }
else if ($d == 0 && $h >= 22 && $h < 23) { $showname = ’ '; }
else if ($d == 0 && $h >= 23 && $h < 0) { $showname = ’ '; }

echo ‘’.$showname.’’;

?>[/php]

Simple, yes? However, as I am to be leaving Uni at the end of this academic year, I can’t count on the fact that the future site maintainers will be able to edit the php, which either way would be a long and boring process. Therefore, I need to automate the script to recognise which show is on air.

All of my show pages are defined by wordpress categories and I’m using a category meta plugin to display extra data.

Therefore, I presume I need to firstly query my show categories (all are a child of category ID 3) by the day and timecode meta that I have defined using the meta plugin:

[php]get_terms_meta($category->term_id, ‘dayvalue’);[/php]
[php]get_terms_meta($category->term_id, ‘timecodestart’);[/php]
[php]get_terms_meta($category->term_id, ‘timecodeend’);[/php]

Then I need to use a function to say IF $dayvalue=1 (for Monday, 2 for Tuesday, 3 for Wednesday etc & 0 for Sunday) and if timecode start is, for example, >12 && <13 …then it displays its category name and $categoryimage for that particular show.

I’ll need to put that same code within the parses for every hour of every day.

That’s the logic - I just don’t know how to code it and there really isn’t much about this area on the net!

As I said, I’m willing to offer the successful person a bit of money because this is quite a crucial part of my project that needs to be completed!

Either respond here or contact me on [email protected].

Sponsor our Newsletter | Privacy Policy | Terms of Service