Jump to content

Random image per day help...


robert.access

Recommended Posts

  • 2 months later...

If you really just want a different image every day, you could use the date function to give you a new filename every day.  No cookies needed.  No cron job needed.  It would just run when the page loads.

 

How many images do you have to choose from?

 

EDIT:  never mind--I didn't read the OP close enough.  Sorry

Link to comment
Share on other sites

Use the date function with z Parameter.

the z Parameter returns the day of year.

now question is, how use a limiter to select a set number of images.

 

quick coding sample

<?php
  header('Content-type: text/plain');
  
  $ads=array('ad01','ad02','ad03','ad04','ad05','ad06','ad07','ad08');
  
  $today=intval(date('z'));
  
   $num_ads=count($ads);
   $i=0;
   while($i++<10)
   {
   $todays_ad=$ads[($today % $num_ads)];
   echo "Todays Ad: $todays_ad\n";
   $today++;
   }
?>

 

Link to comment
Share on other sites

Here a nice way m8.....

 

<?php

$d=array("1"=>"day1.gif","day2.gif","day3.gif","day4.gif","day5.gif","day6.gif","day7.gif","day8.gif"
,"day9.gif","day10.gif","day11.gif","day12.gif","day13.gif","day14.gif","day15.gif","day16.gif",
"day17.gif","day18.gif","day19.gif","day20.gif","day21.gif","day22.gif","day23.gif","day24.gif",
"day25.gif","day26.gif","day27.gif","day28.gif","day29.gif","day30.gif","day31.gif");

$date=date("d");

foreach ($d as $key => $day){

if($date==$key){

echo "$key is $day<br>";
}
}
?>

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.