Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Image rotation by days of the week?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25146

    Hi, I did multiple searches on the forum but i didn’t find any related topics, so please pardon me if this question was asked a lot.

    I have 7 images that I have set for each day of the week, Monday, Tuesday etc for a blog that i’m trying to design. but I think it would be a hassle if i were to use the php made for dates of the month that i found earlier on this site since i have to reassign all images to individual dates. I’m not even sure if php works for blogs because i’m not sure what it is anyway.

    Can anyone guide me? Thanks.

    #59107
    AshtonSanders
    Participant

    I would use the php date function for day of the week:

    Code:
    /images/header.jpg

    That will output a number representation of the day of the week: 1 (for Monday) through 7 (for Sunday)

    So header1.jpg would be Monday’s header.

    #59109
    "AshtonSanders" wrote:
    I would use the php date function for day of the week:

    Code:
    /images/header.jpg

    That will output a number representation of the day of the week: 1 (for Monday) through 7 (for Sunday)

    So header1.jpg would be Monday’s header.

    Thanks but I do not quite understand this. Where am I suppose to place this code? In the <head></head> area? And is that the only line required? Where would my image source be placed?

    Would this work?

    Code:
    /images/header.jpg
    #59110
    AshtonSanders
    Participant

    I’m sorry, I’ll simplify:

    Here is basic PHP:

    Code:

    This will print out a number between 1 and 7 depending on the day of the week: 1 (for Monday) through 7 (for Sunday)

    In general: this is PHP, so it needs to be on a PHP page (not in a .css file)

    So let’s say here’s the HTML code for my image:

    Code:

    I make an image for each day of the week and name them:
    image1.jpg
    image2.jpg
    image3.jpg
    image4.jpg
    etc…

    Now I can change my HTML code to:

    Code:
    .jpg” />

    And that PHP code will be replaced by a number, completing the call for the image.

    (likewise, this can be done in CSS too:

    Code:
    .jpg’)”>

    etc.

    #59291

    Thank you, it seems plausible, but since I’m using this for a blog i can only use images that are hosted on the net itself, like photobucket, I made several images and labeled them with numbers as you suggested but I do not think the code would work like this,

    Code:
    .jpg” width=”100″ height=”210″ />

    Is it possible to incorporate images from images from the web? or is it strictly to hosted images in our domain only thus it can;t be used on blogs?

    #59192
    lyleyboy
    Member

    There is a way around this but the best way would be to host your images somewhere.

    Code:
    “;
    }
    If ($dayNo == 2){
    echo ““;
    }
    ………

    ?>

    Just keep that going for 7 days.

    Don’t forget to escape the " (speech marks) like " or php will error.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.