The code is commented and pretty self explanatory, the only problem is that I am getting only one image (1.jpg) shown all the time.PHP Code:<?php
//
//this is to generate a random picture from a selected directory.
//the image files must follow the pattern: 1.jpg, 2.jpg, 3.jpg.
//
//
//Things to check and change.
//
$folder = "../pic/"; //path to the folder. (html style) (leave trailing slash)
$number = 20; //number of pictures in the folder
//
//The actual program itself.
//
//getting a random number from 1 to whatever user specified.
$random_number = rand(1, 20);
//changing the number into a string for use with the image path.
$random_number = settype($random_number, "string");
//generating the image path.
$image=$folder.$random_number.".jpg";
//displaying the image.
echo "<img src=\"$image\">";
//Volia :)
?>
Could someone tell me where I went wrong? Thanks![]()





Bookmarks