Jump to content


Photo

Help with dropdowns


  • Please log in to reply
2 replies to this topic

#1 Leigh79

Leigh79
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 October 2006 - 12:54 PM

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:


<?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>"; 
?>
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?

Thanks
Leigh

#2 jvrothjr

jvrothjr
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 23 October 2006 - 05:02 PM

echo "<option value='".$row_RS_Listing['Photo1']."'";
if (!(strcmp(0, $row_RS_Listing['Photo1']))) {echo " SELECTED";} 
echo ">".$row_RS_Listing['Photo1']."</option>"; 

If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#3 Leigh79

Leigh79
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 October 2006 - 06:38 PM

Thank you! This is exactly what I needed!!
;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users