Hi All,
I have a combo box that pulls out data from a DB and displays it as values:
[code=php]
<?PHP
// End Functions to pull out areas from DB
function db_result_to_array($result)
{
$res_array = array();
for ($count=0; $row = mysql_fetch_array($result); $count++)
$res_array[$count] = $row;
return $res_array;
}
function get_areas() {
$query=’SELECT * FROM prop_areas ORDER BY the_region’;
$result=mysql_query($query);
if(FALSE==$result)
return false;
if((0 || FALSE)==mysql_num_rows($result)) {
return false;
} else {
$result=db_result_to_array($result);
return $result;
}
}
// End Functions to pull out areas from DB
<FORM NAME=”form1″ METHOD=”post” ACTION=””>
Area: <select class=”input” name=”location” id=”location”>
<option value=”” selected> </option>
<?PHP
$area_array=get_areas();
foreach ($area_array as $thisarea) {
//print_r($thisarea);
print(“<option value=””.$thisarea[‘the_region’].””>”.$thisarea[‘the_region’].”</option>n”);
}
</select>
?>
Now this works fine, but when the user selects the value from the combo box upon submit I want to update another table in mysql database
[code=php]
// Start Update records from database
if(isset($_POST[‘Submit’]))
{
$query = “UPDATE properties SET town = ‘$area_array’ WHERE town = ‘$actual_town'”;
echo “$area_array”;
mysql_query($query) or die (mysql_error());
Now I thought the value of the selected area from the combo box would be $area_array, but when I run my query it updates the table with NOTHING. So what holds the combo box value?
Thanks
Chris