SimonLewis Posted July 19, 2009 Share Posted July 19, 2009 as the title says I been trying to add items from a folder directly into a dropdown list with out any luck can anyone help me oo and would it be possable to add a filter to the handle code so that it would only pickup .gif/jpg files? <? if ($handle = opendir('/public_html/portraits/')){ while (false !== ($Images = readdir($handle))) echo "<select>"; echo "<option name="brand">; echo "<value="$Images">$Images</option>"; echo "</select>"; closedir($handle); } ?> thanks hope sumone can help me Quote Link to comment https://forums.phpfreaks.com/topic/166495-need-help-with-adding-items-from-a-folder-to-a-dropdown-list/ Share on other sites More sharing options...
Daniel0 Posted July 19, 2009 Share Posted July 19, 2009 You need to add curly brackets around the thing in while. Simply indenting the code isn't sufficient. And then the <select> tag should be moved out of course. I.e.: if ($handle = opendir('/public_html/portraits/')){ echo "<select>"; while (false !== ($Images = readdir($handle))) { echo "<option name='brand'>"; echo "<value='$Images'>$Images</option>"; } echo "</select>"; closedir($handle); } Quote Link to comment https://forums.phpfreaks.com/topic/166495-need-help-with-adding-items-from-a-folder-to-a-dropdown-list/#findComment-877970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.