I am trying to create a dynamic dropdown select menu from a directory containing other directories and files. This is to select a certain page from the list so I can edit it. I only want the files in the menu. Here's what I have so far but it doesn't populate the dropdown.

<?php 

$folder = 'tplesystm'; 


echo "<form name=\"subscribe\" action=\"submit.php\" method=\"post\">\n";
echo "<select name=\"folder\">\n"; 
echo "Enter day : <input type=\"text\" name=\"day\">\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Subscribe\">\n";
echo "</form>\n";

if ($dh = opendir($folder)) { 
  while (false !== ($file = readdir($dh))) { 
    if (is_dir($file) && $file != '..' && $file != '.') { 
      echo "<option value=\"$file\">$file</option>\n"; 
    } 
  } 
  closedir($dh); 
} 

echo "</select>\n"; 

?> 

    I think this is what you want to do from the code you posted.

    <?php 
    $folder = "tplesystm";
    echo "<form name=\"subscribe\" action=\"submit.php\" method=\"post\">\n";
    echo "<select name=\"folder\">\n";
    if(( $open = opendir( $folder ) ) != false )
    {
    while( ($read = readdir($open) ) != false )
    {
    if($read!="." && $read!="..") //get rid of (. and ..) dots
    echo "<option value=\"$read\"\>$read</option>\n";
    }
    echo "</select>\n";
    echo "Enter day : <input type=\"text\" name=\"day\">\n";
    echo "<input type=\"submit\" name=\"submit\" value=\"Subscribe\">\n";
    echo "</form>\n";
    closedir($open);
    }
    ?>
      Write a Reply...