Jump to content

Archived

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

Leigh79

Help with dropdowns

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

Share this post


Link to post
Share on other sites
[code=php:0]
echo "<option value='".$row_RS_Listing['Photo1']."'";
if (!(strcmp(0, $row_RS_Listing['Photo1']))) {echo " SELECTED";}
echo ">".$row_RS_Listing['Photo1']."</option>";
[/code]

Share this post


Link to post
Share on other sites

×

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.