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 Quote Link to comment 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>"; Quote Link to comment Share on other sites More sharing options...
BenProl Posted November 26, 2007 Author Share Posted November 26, 2007 Thank you 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.