Results 1 to 2 of 2

Thread: How to assign background image on each day of the week

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to assign background image on each day of the week

    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.

    Code:
    <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>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's PHP code, is your server PHP enabled?

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

    HTML Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •