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: sunbum <mbrashars@gmail.com>
Date: Wed Sep 14 2005 - 19:27:58 CEST

Sorry for replying to my own post.

Here is the latest version and I think it's closer.

Can someone help me clean up the syntax?

Thanks!
------- Code begin (this is NOT in the script ------------------

<?php
if (isset($_POST['file']))
{
    // process the data, see if it's valid.
    // if it's valid and you're satisfied, do whatever you want with
the data
    // if not, start outputting the form

    $file = "/inetpub/wwwroot/templogs/"+$_POST['file'];
    // Display the Graph
    displaygraph();
}

else {
    // display the form
    displayform();
}

<?php
function displaygraph() {
  echo "So far so good, this would draw graph with $file";

}

?>

<?php
function displayform() {

    <form name="cooler" action="<?php $server['PHP_SELF']?>"
method=\"post\">";
    $dir = "/inetpub/wwwroot/templogs/";

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

    <input type="submit" value="Submit">;
    </form>

}

?>

?>

------- Code end (this is NOT in the script ------------------

Mike
Received on Tue Oct 18 02:23:36 2005