Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:37:13+00:00 2026-05-24T06:37:13+00:00

Basically, I have a div with text in it, and I want the background

  • 0

Basically, I have a div with text in it, and I want the background to display a different image depending on what month and year it is.

How can I achieve this?
Any help would be greatly appriciated!


*I’ve prepared 4 years worth of monthly images labelled “month0_2011.png” to “month11_2014.png” already if that helps?*

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:37:15+00:00Added an answer on May 24, 2026 at 6:37 am

    Add a .php extension to the CSS and use PHP code to determine that. Just use standard PHP tags.

    For example:

    body
    {
        background-image:url('<?php echo $currentImagePath ?>');
    }
    

    Where $currentImagePath is the path to your image, determined beforehand (i.e. top of page) using PHP.

    $currentImagePath = $_SERVER['DOCUMENT_ROOT'] . "/css/images/" . "month" . (date("n") - 1) . "_" . date("Y") . ".png";
    

    Putting it all together:

    <?php
    header("Content-type: text/css");
    $currentImagePath = $_SERVER['DOCUMENT_ROOT'] . "/css/images/" . "month" . (date("n") - 1) . "_" . date("Y") . ".png";
    ?>
    
    body
    {
        background-image:url('<?php echo $currentImagePath ?>');
    }
    

    All that is left is adjusting the path to fit your configuration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been battling to get this right...basically I have the following HTML setup: <div
This is a simplified version of what I want to do. Basically I have
I have this HTML structure and want to convert it to an accordion. <div
<div class=contain> <input type=text> </div> So... there is basically what I have. I have
Basically I want to make container with 3 semi-transparent image backgrounds, so I can
You can play with my code here: http://jsfiddle.net/gqQnd/ Basically I want to have a
I have a div set up something like this: <div id=test> <p>Hello</p> <p style=display:
I have a CSS div which contains text (basically, it's a headline). I have
I basically have something like this: void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent);
I basically have three tables, posts, images and postimages (this simply contains the ids

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.