3 Replies - 5770 Views - Last Post: 07 February 2010 - 02:36 PM Rate Topic: -----

#1 Guest_BlissC*


Reputation:

Display image based on date

Posted 07 February 2010 - 09:26 AM

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.

I can't remember where I found the script though. I thought it was here, but after searching around the forums and looking through the PHP code snippets, and 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?

Is This A Good Question/Topic? 0

Replies To: Display image based on date

#2 Guest_BlissC*


Reputation:

Re: Display image based on date

Posted 07 February 2010 - 09:40 AM

(Not quite sure what I've done wrong, as I appear to be logged in, but for some reason I'm showing up as a guest...hmmmmm....)
Was This Post Helpful? 0

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Display image based on date

Posted 07 February 2010 - 09:47 AM

Log out then log back in.
Was This Post Helpful? 0
  • +
  • -

#4 Lochie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 07-February 10

Re: Display image based on date

Posted 07 February 2010 - 02:36 PM

Alright, so here's something that may work for you (using the simple PHP date function):
<?php
$date = date("m,d"); // Returns month followed by day with leading zeros
if($date == "02,14"){
     echo("<img src=\"valentines.jpg\" />");
}
elseif($date == "12,25"){
     echo("<img src=\"christmas.jpg\" />");
}
else{
     echo("<img src=\"default.jpg\" />");
}
?>



etc..

Hope this helps!

This post has been edited by Lochie: 07 February 2010 - 02:39 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1