Jump to content


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


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:

//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>";
//Close Select
echo "</select>";
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:

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


Share this post

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

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.