Jump to content

Need help with adding items from a folder to a dropdown list?


SimonLewis

Recommended Posts

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

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);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.