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

  • SEARCH
  • Home
  • 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 604063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:59:53+00:00 2026-05-13T16:59:53+00:00

Somewhere on my computer I had a PHP script for displaying an image based

  • 0

Somewhere on my computer I had a PHP script for displaying an image based on the date, that would allow me to display different images on specific dates, or between selected dates, and display a default date if the current date wasn’t one listed with a specific image to display.

I recently had a problem with one of my hard drives though and lost a load of files, and I fear this script was one of the ones amongst them, as I can’t find it anywhere.

I can’t remember where I found the script though. I’ve looked all over online and can’t find it again. I thought it was here, but after searching around I can’t find anything vaguely like it, let alone the script itself unfortunately. <_<

Maybe I’m using the wrong search terms (I’ve been trying things like “php display image date”), but I’m finding nothing similar.

Does anyone know of anything fitting the description above, or can suggest the best way to do this?

I’m thinking that I need to specify a default image for if the current date’s got a specific image specified and probably a case/break code block might be a better way to do it than if/else….

Anyone got any thoughts on the best way to do this?

Edit: Thanks everyone for your suggestions. I wasn’t especially keen on using if/else/elseif, but in the end it seemed the easiest way to accomplish it. The way I’ve done it’s probably not the most efficient way code-wise, but it works for now.

(part of the code – it’s rather long, so I won’t bore you with it all)

“Hmmm….okay, thanks. That explains why what I was trying to do wasn’t working! 😆

Though I have seen other ways of doing it, including a foreach loop and GD, I stuck with the if/elseif/else in the end. It’s probably not the most efficient way code-wise of doing it, but this worked in the end (part of the code anyway – it’s a very long list, and I won’t bore you with all of it!):

<?php 
    // Macmillan Cancertalk week (21-25 Jan)
    if ((date('m') == 01) && (date('d') >= 21) || (date('m') == 01) && (date('d') <= 23)) {
    echo "<img src=\"images/ribbons/cancertalk.gif\" height=\"145\" width=\"175\" alt=\"Macmillan Cancertalk\" /><br /><h6 class=\"awareness\">Macmillan Cancertalk Week <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }   
    // Macmillan Cancertalk week (21-25 Jan) and Cervical Cancer Awareness Week (24-30 Jan) 
    else if ((date('m') == 01) && (date('d') == 24)) {
    echo "<img src=\"images/ribbons/macmillan_cervical.gif\" height=\"145\" width=\"175\" alt=\"Macmillan Cancertalk and white and teal awareness ribbons\" /><br /><h6 class=\"awareness\">Macmillan Cancertalk Week &amp; Cervical Cancer Awareness Week <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }   
    // Macmillan Cancertalk week (21-25 Jan), Cervical Cancer Awareness Week (24-30 Jan) and Beating Bowel Cancer - Be Loud Be Clear Week (25-31 Jan)   
    else if ((date('m') == 01) && (date('d') == 25)) {
    echo "<img src=\"images/ribbons/macmillan_cervical_bowel.gif\" height=\"145\" width=\"175\" alt=\"Macmillan Cancertalk, white & teal awareness ribbons, and blue & brown cancer awareness ribbons\" /><br /><h6 class=\"awareness\">Macmillan Cancertalk Week, Cervical Cancer Awareness Week, and Be Loud Be Clear Week (Beating Bowel Cancer) <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }
    // Beating Bowel Cancer - Be Loud Be Clear Week (25-31 Jan) 
    else if ((date('m') == 01) && (date('d') == 31)) {
    echo "<img src=\"images/ribbons/brown_blue_ribbon.gif\" height=\"145\" width=\"175\" alt=\"blue and brown cancer awareness ribbons\" /><br /><h6 class=\"awareness\">Be Loud Be Clear Week (Beating Bowel Cancer) <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }   
    // International Childhood Cancer Day (15 Feb)
    else if ((date('m') == 02) && (date('d') == 15)) {
    echo "<img src=\"images/ribbons/gold_ribbon.gif\" height=\"145\" width=\"175\" alt=\"gold cancer awareness ribbons\" /><br /><h6 class=\"awareness\">International Childhood Cancer Day <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }       
    // Gynaecological Cancers Campaign (1 Feb to 31 March)
    else if ((date('m') == 02) && (date('d') >= 01) || (date('m') == 02) && (date('d') <= 28)) {
    echo "<img src=\"images/ribbons/teal_ribbon.gif\" height=\"145\" width=\"175\" alt=\"teal cancer awareness ribbons\" /><br /><h6 class=\"awareness\">Gynaecological Cancers Campaign (1st February &ndash; 31st March) <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6>";
    }   
    else {
    echo "<a class=\"awareness_link\" href=\"the-bookstall-cancer-links-and-resources.php\"><img src=\"images/ribbons/default_ribbon.gif\" height=\"145\" width=\"175\" alt=\"calendar\" /><br /><h6 class=\"awareness\">Check our awareness calendar for information about awareness events &ndash; <span class=\"morelink\"><a href=\"the-bookstall-cancer-links-and-resources.php\">more...</a></span></h6></a>";
    }
?>
  • 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-13T16:59:53+00:00Added an answer on May 13, 2026 at 4:59 pm

    you could use the date() function to check for the current month/day/year and some simple if/else constructs to show different images.

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

Sidebar

Ask A Question

Stats

  • Questions 445k
  • Answers 445k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Creating one global Entity Framework DbContext in a web application… May 15, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer Do not use shared_ptr or scoped_ptr to hold pointers to… May 15, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer It turns out that I had only compiled the app… May 15, 2026 at 6:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.