SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random Image Block

    Could somebody show me how to make a php page that read the images in specific thumbnail dir, and then display it randomly in the homepage? thanks.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just change the path to your thumbs dir.
    PHP Code:
    <?php
    //Relative path to your thumbs dir
    $dir "images/thumbs/";
    $d dir($dir);
    while(
    $f $d->read()) {
        if(
    $f != '.' && $f != '..') {
            
    $files[] = $f;
            }
        }
    srand((double) microtime() * 10000);
    $randval rand(0count($files) - 1);
    $randimage =  $dir.$files[$randval];    
    ?>
    <img src="<?php print $randimage?>">
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •