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
https://forums.phpfreaks.com/topic/96394-change-content-on-specific-dates/
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 
}
?>

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'/>";
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.