Re: Populate picklist from directory and return file name
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Populate picklist from directory and return file name

From: Sandman <mr@sandman.net>
Date: Tue Sep 13 2005 - 08:02:46 CEST

In article <rInVe.14457$ct5.12705@fed1read04>,
 "Mike Brashars" <mike@apayrollservice.com> wrote:

> Hi all,
>
> I have been searching for a week and am unable to find and example to
> "Populate picklist from directory and return file name".
>
> I have a php script that reads a log file and plots a graph. Right now, the
> log name is hard coded. The logs are archived each day in the form of say
> ddmmyy.log and I would like to put a drop down list in the script that would
> allow my script to run off the "log" picked or default to the current "hard
> coded" name.
>
> I thought this would be a really common thing but I guess not.
>
> I would be open to a javascript or asp script as long as I could "feed"
>
> the file name to my php script.
>
> Can anyone point me to a script like this??
>
> Thanks a million!

<?
    # Directory
    $dir = "/path/to/a/dir/";

    print "<select name='file'>";
    while (false !== ($file = readdir($dir))){
        if (in_array($file, array(".", ".."))) continue;
        print "<option value='$file'>$file</option>";
    }
    print "</select>";

?>

-- 
Sandman[.net]
Received on Mon Oct 24 02:09:58 2005