Leigh79 Posted October 23, 2006 Share Posted October 23, 2006 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?ThanksLeigh Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted October 23, 2006 Share Posted October 23, 2006 [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] Quote Link to comment Share on other sites More sharing options...
Leigh79 Posted October 23, 2006 Author Share Posted October 23, 2006 Thank you! This is exactly what I needed!! ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.