random pics

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prophet

    #1

    random pics

    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


  • Ed Mullen

    #2
    Re: random pics

    prophet wrote:
    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.


    --
    Ed Mullen
    Help for Mozilla, Firefox and SeaMonkey. Performances and original music.

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

    Comment

    • while-one

      #3
      Re: random pics

      On Apr 13, 7:48 pm, "prophet" <M_Mo...@hotmai l.comwrote:
      ......or do it server-side with a scripting language, perhaps php

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

      srand((double)m icrotime()*1000 000);
      $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);
      }

      Comment

      Working...