Jump to content


Drop down


2 replies to this topic

#1 Bl4ck-Vip3r

    Young Padawan

  • Members
  • Pip
  • 41 posts

Posted 01 April 2007 - 05:27 AM

Is there a way i can get a dropdown box to automatically list the file names of a folder?

I have an avatars folder and to save me making mistakes typing the name i want i want to just select from a dd box.

#2 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 01 April 2007 - 05:47 AM

put

<select name='file'>
<?

//define the path as relative
$path = "changeme";

//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");

//running the while loop
while ($file = readdir($dir_handle)) 
{
 if($file!="." && $file!="..")
   echo "<option value='$file'>$file</option>";
}

//closing the directory
closedir($dir_handle);

?>
</select>

change $path ofcourse

Edited by curthard89, 01 April 2007 - 05:49 AM.


#3 Bl4ck-Vip3r

    Young Padawan

  • Members
  • Pip
  • 41 posts

Posted 01 April 2007 - 06:36 AM

Thanks man you been a great help!! :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users