Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.