/    Sign up×
Community /Pin to ProfileBookmark

Value of a Combo Box

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>
?>
[/code]

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());
[/code]

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

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 30.2006 — $_POST['location']
×

Success!

Help @chrisb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...