random pics

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am new to this so sorry for what is probably a simple question...

I want to have a picture that changes at random each time you go to the page
so that it is different.

Thank you

Re: random pics

prophet wrote:
Quoted text here. Click to load it


Ed Mullen
Why do we say something is out of whack? What is a whack?

Re: random pics

 ......or do it server-side with a scripting language, perhaps php

function randPicName()
   $dir = opendir("/var/www/my-site/my-images/my-rands");
   while ( $file = readdir($dir))
      if($file[0] != ".")  /// or call some fancier isImage function
        $pics[$cnt] = trim($file);

  $randval = rand(2,$cnt);
  $pic = $pics[$randval];

  /// this is an image name only, so you'd
  /// have to prepend a path to make an img src url with it.
  return ($pic);

Site Timeline