View Full Version : Random Image By Day.

12-14-2006, 09:49 AM

I'm using a phpBB mod called ezPortal,well I made a block to add a random image by day,for example if it's monday i would like a script that could select the images for monday and display them randomly. A few months ago someone here helped me get a great random image script that has sessions :


$image = array(
'image' => 'images/image.jpg',
'link' => 'http://url.com'
'image' => 'images/image.jpg',
'link' => 'http://url.com'

$_SESSION['curing'] = rand(0, count($image) - 1);

$image = $image[$_SESSION['curing']];

$image = '<a href="' . $image['link'] . '" target="_top"><img src="' . $image['image'] . '" border="0"></a>';

<?php echo($image); ?>

Can anyone help me maybe modify this script a bit to display the images by the day?

Thanks for your time



12-14-2006, 10:43 PM
Ok i found a cool random image by day script,but since Im a php noob i was wondering if you could help me modify it a bit to my needs.


* Change the name of the image folder
* Images must be named Monday.gif, Tuesday.gif etc

// Change to the location of the folder containing the images
$image_folder = "templates/bLock/rotating/";

// You do not need to edit below this line

$today = date('l');

if (file_exists($image_folder."/".$today.".gif")) {
echo "<img src=\"$image_folder/".$today.".gif\">";
else {
echo "No image was found for $today";


This script selects the image from a folder like Monday.gif Tuesday.gif, I wanted to have multi images for that day.Would it be possible to instead of select from one folder it can select from 7 diff ones named /Monday Tuesday/ ect... so that I can upload the pictures i would like to appear on a specific day to its respective folder.

Another problem is the date,it uses the servers date and not mine. Is there anyway I could specify it to get the date from a time server like time.microsoft.com ?

Thanks for your help