Log in

View Full Version : How to assign background image on each day of the week



HairRaiser
04-07-2011, 04:14 AM
Hello everyone, I'm new here. I've been trying to find a solution for my problem (above), and maybe if anybody here can help me out. I used this code but the background image didn't change after 24hrs.


<style type="text/css">
body{background: url(images/<?php
$day = strftime('%A');

if($day == 'Monday') echo 'monday';
elseif($day == 'Tuesday') echo 'tuesday';
elseif($day == 'Wednesday') echo 'wednesday';
elseif($day == 'Thursday') echo 'thursday';
elseif($day == 'Friday') echo 'friday';
elseif($day == 'Saturday') echo 'saturday';
elseif($day == 'Sunday') echo 'sunday';
?>.jpg) no-repeat left top;}
</style>

jscheuer1
04-07-2011, 05:13 AM
That's PHP code, is your server PHP enabled?

The code appears to work on my PHP sandbox (WAMP), it generated today (Thursday):


<style type="text/css">
body{background: url(images/thursday.jpg) no-repeat left top;}
</style>

So you would have to have a thursday.jpg in the images folder just off of the folder that this page is in. If so, it should work, unless you had another stylesheet or inline style after it that changed the body's background.

There are other things that could possibly affect this though.

If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.