argrafic Posted May 6, 2008 Share Posted May 6, 2008 Hello all. I have the insert form that has 3 list/menus. When I want to update a record I gather all the information and show it with a form. My problem is with the values the list/menus have, because so far they appear with the default value which if the user doesn't see might overwrite withouth their knowledge the wrong value. How can I get the list/menu to match the value saved in the database? Thanks! Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/ Share on other sites More sharing options...
ILYAS415 Posted May 6, 2008 Share Posted May 6, 2008 Wow thats very confusing. Can you make it a little simpler please? Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/#findComment-534401 Share on other sites More sharing options...
argrafic Posted May 7, 2008 Author Share Posted May 7, 2008 sorry... i have the regular insert form that has 3 list/menus, one gets the values from the database, the others have "static" content. then i also have a update form for the values stored in the database for the insert form. my issue is that when i load the info to the update form i want to know if there is a way that for the list/menus the option that appears is the one stored in the database and not the first value in the list/menu. i don't know... i hope i explained it better... Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/#findComment-535380 Share on other sites More sharing options...
benphp Posted May 7, 2008 Share Posted May 7, 2008 Do something like this: <?php //DROPDOWN MENU: Category $selectcat = "SELECT catname FROM icategory order by catorder"; $resultcat = mysql_query($selectcat) or trigger_error("SQL", E_USER_ERROR); while($cat = mysql_fetch_row($resultcat)) //set $row to a row array from the query results { $catMenu = $cat[0]; //assign a var to each element in the array if ($catMenu == $pcategory) { $cats = $cats . "<option value=\"$catMenu\" selected>$catMenu</option> "; } else { $cats = $cats . "<option value=\"$catMenu\">$catMenu</option> "; } } //End DROPDOWN MENU: Category ?> and insert the $cats into your <select> <?php print "<select name=\"pcategory\">$cats</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/#findComment-535385 Share on other sites More sharing options...
argrafic Posted May 8, 2008 Author Share Posted May 8, 2008 thanks. another doubt, with this i could also add all the other options to the dropdown? Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/#findComment-535962 Share on other sites More sharing options...
argrafic Posted May 9, 2008 Author Share Posted May 9, 2008 Awesomeeee!!!! Thanks ben!!!! Link to comment https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/#findComment-536897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.