BenProl Posted November 26, 2007 Share Posted November 26, 2007 Hi all, I've been looking at PHP for about a week so apologies in advance for any poor form... I'm building a form for editing page content. It's pretty simple, a moderator clicks on the page that they want to edit and the form fields are then pre-populated with the page data from the database. I've managed to achieve this for every field apart from the drop-down menu. Obviously, I need the pre-selected option to be the correct one, but right now it isn't populating the menu at all. <select name="subject_id" id="subject_id" tabindex="1"> <?php $locations_query = "SELECT * FROM vacancy_locations ORDER BY position ASC"; $locations_set = mysql_query($locations_query, $connection); confirm_query($locations_set); while ($location_data = mysql_fetch_array($locations_set)) { echo "<option value='{$location_data["menu_name"]}'"; if ($pg_data['subject_id'] == $location_data['id']) { echo " selected"; } } echo "></option>"; ?> </select> Any help? Many thanks, BenH Link to comment https://forums.phpfreaks.com/topic/78912-solved-populating-drop-down-menu/ Share on other sites More sharing options...
koen Posted November 26, 2007 Share Posted November 26, 2007 What about: echo ">{$location_data["menu_name"]}</option>"; Link to comment https://forums.phpfreaks.com/topic/78912-solved-populating-drop-down-menu/#findComment-399377 Share on other sites More sharing options...
BenProl Posted November 26, 2007 Author Share Posted November 26, 2007 Thank you Link to comment https://forums.phpfreaks.com/topic/78912-solved-populating-drop-down-menu/#findComment-399378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.