Hey,
Trying to get a value from a SQL SELECT to use in a drop down list while editing a selected meetings data.
The variable $row->areaid is coming from a seperate select which is searching a different table to get all of the information on the selected meeting.
The drop down list gets all of it's options from a database, so the list is dynamic. What I want to be able to do is have the option that relates to the selected meeting I am trying to edit, to show.
At the moment the last select option shows, now the specific meeting.
Here is the code for the problem I am having.
<?
// generate query
$query2 = "SELECT subarea_name FROM MEETINGS_AREAS_SUB WHERE area_id=$row->areaid ORDER BY subarea_name ASC";
$result2 = mysql_query($query2) or die("Couldn't execute query.");
// if a result is returned
if (mysql_num_rows($result2) > 0)
{
$subarea = $_POST["subarea_name"];
?>
<select name="area" id="area">
<option value=''></option>
<?
// Creates the Area dropdown
while(list($subarea_name) = mysql_fetch_row($result2)) {
echo '<option value="'.$subarea_name.'"';
if ($_GET['subarea_name'] == "$subarea")
{
echo ' selected';
}
echo '>'.$subarea_name.'</option>';
}
?>
</select>
<?
}
else
{
echo "No areas could be found, please add some.";
}
?>
[CODE]
Any ideas what I am doing wrong?
Cheers,
Chris