Forum Moderators: coopster

Message Too Old, No Replies

Include/Show File for Specified Dates

Not sure how to word this...

         

EarleyGirl

6:04 pm on Jan 21, 2006 (gmt 0)

10+ Year Member



Hi all,

I'm looking for a script that will switch out gif images depending on the date. For example, November through December, the site will show a Christmas image. Then mid January though Feb 14th, a Valentine's day image. Can anyone recommend a script? I tried searching for one but I must be using the wrong keywords.

TIA,

Hope

coopster

11:16 pm on Jan 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why not write your own code? It would be quite easy actually. Check the date [php.net] on the server and assign your image name accordingly.

EarleyGirl

11:26 pm on Jan 21, 2006 (gmt 0)

10+ Year Member



Hi coopster. So sorry... I should have mentioned that though I can wade through installing a script, I can't write one as yet. Still too new for that.

coopster

11:46 pm on Jan 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you are going to be installing PHP scripts you may certainly want to have an understanding of how PHP works, no? If for nothing else, security alone! This is a good opportunity to get your PHP programming feet wet ;-)

All you have to do is determine the current date and then use a control structure [php.net] to choose the correct image.

You could start with something like this and work with it until you get what you want. Along the way, you'll pick up some programming skills!

<?php 
$date = date('md'); //mmdd format
switch (true)
{
case ($date > '1031'):
// November 1 - December 31
$image = 'nov-dec.gif';
break;
case ($date > '0731'):
// July 31 - October 31
$image = 'nov-dec.gif';
break;
default:
$image = 'default.gif';
}
print $image;

EarleyGirl

1:36 am on Jan 22, 2006 (gmt 0)

10+ Year Member



I know... I need to learn how to fish!

Thank you so much for giving me a head start, coopster! This looks great.

Hope