I have this drop down list, displaying all the files from a folder, one of which will be selected for use. Is there a way to show which file is selected when you load the page? at the moment it says "select a file" every time.
<select name="image" type="text" class="box" id="image" value="<?=$image;?>">
<option value='empty'>Select a file</option>
<?php
$dirname = "images/";
$images = scandir($dirname);
// This is how you sort an array, see http://php.net/sort
natsort($images);
// There's no need to use a directory handler, just loop through your $images array.
foreach ($images as $file) {
if (substr($file, -4) == ".gif") {
print "<option value='$file'>$file</option>\n"; }
}
?>
</select>