Jump to content

[SOLVED] Populating drop down menu


BenProl

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.