Jump to content

Change content on specific dates..


psquillace

Recommended Posts

Hello All:

 

I want to write a script where a few .jpgs that I have would change on a specific date (seasonally). Being new to php I was wondering if I should do something like

 

IF date() 'img src"" ' ;

 

}else{

 

echo img... bla bla bla

 

but I am not sure of the exacts of how I can do this,

 

Any help or advice is much appreciated,

 

Paul

 

Link to comment
Share on other sites

what are your seasons that you want to change it on? You can use the date command to find

out the current date,time, month, etc and then compare it to your pre-made selection, ie:

 

<?php
if(date("m") >=11 && date("m") <=04)
{
  //winter
} elseif(date("m") >=05 && date("m") <=06) {
  //spring
} elseif(date("m") >=07 && date("m") <=10) {
//summer
} else {
//fall 
}
?>

Link to comment
Share on other sites

Better all year example..........

 


<?php

$x=array("01"=>"january.jpg","02"=>"febuary.jpg","03"=>"march.jpg",
          "04"=>"april.jpg","05"=>"may.jpg","06"=>"june.jpg","07"=>"july.jpg",
          "08"=>"august.jpg","09"=>"september.jpg","10"=>"october.jpg",
          "11"=>"november.jpg",
          "12"=>"december.jpg");

$date=date("m");

foreach($x as $key=> $val){

if($date==$key){

	echo"<img src='$val'/>";
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.