here is a function to read the contents of a directory that then pulls it
into a drop down select list.  You may want to modify it for your needs but
this should work for you.

$dir_name = "/virtual/path/to/images/directory/";
$dir = opendir($dir_name);
$file_list .= "<p><FORM METHOD=\"post\" ACTION=\"images_done.php3\"
NAME=\"images\">
<SELECT NAME=\"images\">";
 while ($file_name = readdir($dir)) {
  if (($file_name != ".") && ($file_name !="..")) {
  $file_list .= "<OPTION VALUE=\"$file_name\"
NAME=\"$file_name\">$file_name</OPTION>";
  }
 }
 $file_list .= "</SELECT><br><br><INPUT TYPE=\"submit\" NAME=\"submit\"
VALUE=\"select\"></FORM></p>";
 closedir($dir);
HTH
Jas

"Ashley M. Kirchner" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>     Take this function:
>
>       function randomImg() {
>         $numargs = func_num_args();
>         $ImgArray = array($numargs-1);
>         $arg_list = func_get_args();
>         $ImgDir = $arg_list[0];
>         srand((double)microtime()*1234567);
>         $img = $arg_list[rand(1,count($arg_list)-1)];
>         while(!$img) {
>           $img = $ImgArray[rand(1,count($ImgArray))];
>         }
>         return "$ImgDir/$img";
>       }
>
>
>     ...it assumes two things:  $arg_list[0] is a variable (which is always
> passed) that ends up being $ImgDir, and then there's $arg_list[1-n] where
'n'
> is >1 .  Right now, I'm calling this function like so:
>
>     <? echo randomImg("home", "bg01.gif", "bg02.gif", "bg03.gif"); ?>
>
>     However, I'd like to change it so that I don't have to specify the
image
> names ($arg_list[1..n]), but just the first variable.  I'd like for it to
grab
> whatever it finds in that folder (passed as the variable), and use.  This
way I
> can have any number of images in that folder without having to edit my
pages
> every time to add or remove more.  And what if the image name changes,
once
> again I have to manually fix the function call in my pages.
>
>     Can PHP do this; open that directory, read its contents and use it (if
so,
> how?)  Or do I have to go to Perl for this?
>
> --
> W | I haven't lost my mind; it's backed up on tape somewhere.
>   +--------------------------------------------------------------------
>   Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
>   IT Director / SysAdmin / WebSmith             .     800.441.3873 x130
>   Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave. #6
>   http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to