Populate A 'select List' From A Directory On My Server Using Php And Html June 25, 2024 Post a Comment Is it possible (I am assuming not) to populate a drop down list from files that are on my website, say in the images folder? in a html form? Solution 1: You can use scandir - http://php.net/manual/en/function.scandir.phpThen just run a foreach on the returned array and echo <option> for each one.Solution 2: Try it like this:<selectname="s1"><optionvalue=""selected="selected">-----</option><?phpforeach(glob(dirname(__FILE__) . '/images/*') as$filename){ $filename = basename($filename); echo"<option value='" . $filename . "'>".$filename."</option>"; } ?></select>Copy Share Post a Comment for "Populate A 'select List' From A Directory On My Server Using Php And Html"
Post a Comment for "Populate A 'select List' From A Directory On My Server Using Php And Html"