46 users online (1 members and 45 guests)  


  Results 1 to 4 of 4

Related

  1. Random Images    Forum: PHP Forum
    Replies: 1
  2. Random Images using CSS files    Forum: CSS Forum
    Replies: 3
  3. Random Images Advanced    Forum: HTML Forum
    Replies: 4
  4. Replies: 0
  5. multiple random images    Forum: PHP Forum
    Replies: 21
  1. #1
    isleysista's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2003
    Posts
    2

    random images php script

    Does anyone know of an easy-for-beginner's php script (or another one) that allows for images to change with the click of the refresh button? Preferably one that pulls images from a diretory/file instead of a text file.

    thanks

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    Last edited by HTML; 03-23-2009 at 04:31 PM.

  3. #3
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    I dont know one offhand. However, I did write a 'random signature' script for display in the various gaming forumm I play in. With a little amendment, it should do what you need-

    heres the link that shows the source, remove everything after the ? for it to work normally -

    http://www.quietdean.com/random.php?mode=showme
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  4. #4
    christodd's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Tacoma, Washington
    Posts
    20
    Quote Originally Posted by isleysista
    Does anyone know of an easy-for-beginner's php script (or another one) that allows for images to change with the click of the refresh button? Preferably one that pulls images from a diretory/file instead of a text file.

    thanks
    Sure... he're a simple one

    PHP Code:
    <?
     $i
    =0;
     
    $path="images"// change to you image directory
     
    $ext "jpg"// change to your file extension
     
    $extra"alt=\"Random Image\" float=\"left\""// additional <img> params
     
    if ($handle opendir($path)) { 
        while (
    false !== ($file readdir($handle))) { 
        if (
    substr($file,strlen($file)-3,3)==$ext
    {        
    $imgs[$i++]=$file;
    }
        }
       
    closedir($handle); 
      
    $today=getdate();

    //uncomment this line to get the same image all day
    //   srand($today['mday']+$today['month']+$today['year']); 

       
    $r=rand(0,$i-1);

       echo(
    "<img src=\"$imgs[$r]\" $extra>");

     }

    ?>

    -Chris
    Last edited by HTML; 10-31-2003 at 05:12 PM.



Tags for this Thread