AZForums: Random Images - AZForums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Random Images PHP Tutorial

#1 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 27 December 2005 - 09:16 PM

Want a simple random image script? Here it is!

<?php
$dir="./";
$nimg="10";
$itype="jpg";
$bor="1";

$rnumb=rand(1,$nimg);

echo "<img src="".$dir."".$rnumb."".$itype."" border="".$bor."">";
?>


How To Use It:
$dir="./"; - This is the path (directory) to the images, it must include the foward slash.
$nimg="10"; - Number of images in the folder.
$itype="jpg"; - The image type (don't Include the ".").
$bor="1"; - The image border, 0 is no border, 1 is a 1 pixel border.

Add the code the where ever you want it to apprear on the web page.
Make sure the web page file type is .php.
All image names must be a number (Example: 1.jpg 2.jpg 3.jpg).

Hope this is useful.
0

#2 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 09 January 2006 - 05:13 PM

This tutorial has now been added to http://www.pixel2life.com XD

As of this post...it's currently the first listed on the main page (20 Latest Tutorials), but it will move on soon...

Find it under:
http://www.pixel2lif...PHP_Coding/All/ - (Main PHP list)
-OR-
http://www.pixel2lif...e_and_Rotation/ - (Randomize and Rotation...the actual section it is listed under).

Please rate it...(10 of course :P)

I am happy.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users