mitch.james31
New Member
- Messages
- 2
- Reaction score
- 0
- Points
- 0
Hi there...
I am trying to use a PHP script to make a different image show depending on what time it is.
For some reason, It only ever displays the image for if $time = 1...
I'm pretty new to PHP, and I have spent a few hours trying to get it to work with no success ... Has anybody got any ideas or solutions?
Many thanks,
mitch.james
I am trying to use a PHP script to make a different image show depending on what time it is.
PHP:
<?php
date_default_timezone_set('UTC');
$time = date("H");
function changebg() {
if ($time = 01) {echo "images/headernight.gif";}
elseif ($time = 02) {echo "images/headernight.gif";}
elseif ($time = 03) {echo "images/headernight.gif";}
elseif ($time = 04) {echo "images/headernight.gif";}
elseif ($time = 05) {echo "images/headernight.gif";}
elseif ($time = 06) {echo "images/headerday.gif";}
elseif ($time = 07) {echo "images/headerday.gif";}
elseif ($time = 08) {echo "images/headerday.gif";}
//etc.. through to $time = 23
else {echo "images/headerday.gif";}
}
?>
//and then in the HTML body...
<td height="175" style="background: url(<?php changebg();?>)"> </td>
I'm pretty new to PHP, and I have spent a few hours trying to get it to work with no success ... Has anybody got any ideas or solutions?
Many thanks,
mitch.james