My PHP's Random Images

| No Comments
You saw the random image above the daveynin's thing banner title image above and saw random photos in my main homepage.

How do I do that? I created PHP few lines to make image random. Here is the code:

<?
$lower = 1;    // set the starting number
$upper = 11;     // set the finishing number, total of images
$random_number = mt_rand($lower, $upper);  // random to pick a number
$image = "$random_number.jpg"; // convert into file name

echo "<img src='images/david_random/$image' alt='$image' border='0'">
?>

You need to place the images into directory path, and count the total of images, and insert the total of images in $upper variable.

If you don't have PHP, you can try this in JavaScript, it has more lines and work than I do. ;-)

Archives

Master Archives

What am I doing

    Tag cloud

    View All Tags

    SUBSCRIBE

    Powered by Movable Type 4.23-en