Recent Topics

random images script

Started by on Jun 07, 2007 – Contents updated: Jun 07, 2007

Jun 07, 2007 22:17    

Hey I went through a few of the suggestions for having random images show up on the blog and I couldnt find anything that fit my needs. I found this really simple scrcipt you can use.

Code

<?php
 
/*
* Name your images 1.jpg, 2.jpg etc.
*
* Add this line to your page where you want the images to
* appear: <?php include "randomimage.php"; ?>
*/
 
// Change this to the total number of images in the folder
$total = "11";
 
// Change to the type of files to use eg. .jpg or .gif
$file_type = ".jpg";
 
// Change to the location of the folder containing the images
$image_folder = "images/random";
 
// You do not need to edit below this line
 
$start = "1";
 
$random = mt_rand($start, $total);
 
$image_name = $random . $file_type;
 
echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />";
 
?>

i am no php guru, just trying to give back a little.
credit for this goes to:
http://www.totallyphp.co.uk/scripts/random_image.htm

cheers!


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.