php picture change code

jay1989

New Member
hi i need some help with this php code
is changes our dj's pictures on a day and time or hour?
but i want to work at these days and times
wednesdays and thursdays 6pm till 8pm

heres the code

<?php
$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.
// Adjust 2 hour offset for MST below.
$h = $h+1;


// MONDAY SCHEDULE
if ($d == 1 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 4 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 8 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 12 && $h < 14) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 14 && $h < 16) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 16 && $h < 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h >= 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// TUESDAY SCHEDULE
if ($d == 2 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 4 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 8 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 12 && $h < 13) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 13 && $h < 15) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 15 && $h < 17) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 17 && $h < 20) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 2 && $h >= 20) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// WEDNESDAY SCHEDULE
if ($d == 3 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 4 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 8 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 12 && $h < 13) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 13 && $h < 15) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 15 && $h < 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 3 && $h >= 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// THURSDAY SCHEDULE
if ($d == 4 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 4 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 8 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 12 && $h < 13) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 13 && $h < 15) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 15 && $h < 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 4 && $h >= 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// FRIDAY SCHEDULE
if ($d == 5 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 4 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 8 && $h < 10) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 10 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 12 && $h < 13) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 13 && $h < 15) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 15 && $h < 18) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 18 && $h < 20) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 20 && $h < 22) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 5 && $h >= 22) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// SATURDAY SCHEDULE
else if ($d == 6 && $h >= 0 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 4 && $h < 5) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 5 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 8 && $h < 9) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 9 && $h < 10) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 10 && $h < 11) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 11 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 12 && $h < 13) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 13 && $h < 14) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 14 && $h < 15) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 15 && $h < 17) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 17 && $h < 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 19 && $h < 22) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 6 && $h >= 22) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';


// SUNDAY SCHEDULE
else if ($d == 0 && $h >= 0 && $h < 2) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 2 && $h < 4) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 4 && $h < 5) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 5 && $h < 6) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 6 && $h < 8) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 8 && $h < 9) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 9 && $h < 10) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 10 && $h < 11) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 11 && $h < 12) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 12 && $h < 16) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 16 && $h < 17) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 17 && $h < 18) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 18 && $h < 19) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 19 && $h < 21) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 0 && $h >= 21) $img = '/images2/dj/images/dj_dog.jpg';
else if ($d == 1 && $h < 0) $img = '/images2/dj/images/dj_dog.jpg';
?>


<html>
<head></head>
<body>
<p align="center"><img src="<?php echo $img; ?>"> </p>
<p>&nbsp;</p>
<p align="center">


</body>
</html>
 
Hi jay1989,

We don't have any php programmers here we are afraid. But we do recommend to you the programming support site 'Stack Overflow' which may be of some assistance to you. Stack Overflow
 
Top