Re: Re: drop down menu populated from a directory
| From: | Dustin Krysak | Date: | Mon, 31 May 2004 17:26:18 +0000 |
| Subject: | Re: Re: drop down menu populated from a directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187288@lists.php.net to get a copy of this message | ||
I gave it a go, and I got the error:
"Parse error: parse error, unexpected '}'"
This was on the last "}". Now I am brand new at php, but should there not be an opening and closing curly bracket? in this code there are one "{" and three "}"
So I made my code:
<?php
if ($handle = opendir('../../../mov')) {
while (false !== ($file = readdir($handle)))
if ($file != '.' && $file != '..')
$fileName = str_replace('.mov', '', $file);
echo '<option value="' . $file . '">' . $fileName . '</option>';
closedir($handle);
}
?>
And it does display the name in the menu... so that is a good start, but the link doesn't work when selected. So I am assuming hte code does need those brackets, and I rather need to open the opening one...
d
On 31-May-04, at 2:39 AM, php-general-digest-help@lists.php.net wrote:
From: "Torsten Roehr" <roehr@zilleon.com> Date: May 30, 2004 5:14:28 PM PDT To: php-general@lists.php.net Subject: Re: drop down menu populated from a directory "Dustin Krysak" <mailinglists@digitalcollision.com> wrote in message news:B965865C-B293-11D8-8990-000A95902366@digitalcollision.com...Hi there.... What I am hoping to do is have a drop down menu that would be populated from the contents of a directory via php. Now The link names would be generated by the file name minus the file extension. Has anyone seen a tutorial on accomplishing something like this? All of the links would be to quicktime movies, but I am hoping to have them embedded in HTML (or PHP)..... So the movie is displayed in a browser.... thanks in advance!This should do the trick: // opening select tag goes here... if ($handle = opendir('/path/to/files')) { while (false !== ($file = readdir($handle)))if ($file != '.' && $file != '..')$fileName = str_replace('.mov', '', $file); echo '<option value="' . $file . '">' . $fileName . '</option>'; }} closedir($handle); } // closing select tag goes here Haven't tested it. Hope it works and helps ;) Regards, Torsten Roehr