[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]()
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]()
Drivetime');
} elseif (($today['hours'] >= 19 && $today['hours'] <= 21) ){ echo('
The Evening Show');
} elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('
![The Late Bit]()
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]()
Classics
');
} elseif (($today['hours'] >= 21 && $today['hours'] <= 24) ){ echo('
![Beats]()
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.