Jump to content

Help with dropdowns


Leigh79

Recommended Posts

Hope someone can help me...

I have an insert form where several of the dropdown menus have values which are generated by pulling file contents (images) in to an array:


[code]
<?php
//Looks into the directory and returns the files, no subdirectories
    echo "<select name='Photo1'>";
echo "<option value='NA'>NA</option>";
//The path to the style directory
    $dirpath = "../images/properties/";
    $dh = opendir($dirpath);
      while (false !== ($file = readdir($dh))) {
//Don't list subdirectories
          if (!is_dir("$dirpath/$file")) {
//Truncate the file extension and capitalize the first letter
          echo "<option value='$file'>$file</option>";
  }
}
    closedir($dh); 
//Close Select
echo "</select>";
?>
[/code]
I'm now building an edit page and I need to set the value of the dropdown according to whats in the database, the code for which would be this:

[code]
<?php if (!(strcmp(0, $row_RS_Listing['Photo1']))) {echo "SELECTED";} ?>
[/code]
can anyone tell me how to incorporate these 2 snippets?

Thanks
Leigh
Link to comment
Share on other sites

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.