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