/    Sign up×
Community /Pin to ProfileBookmark

Slowly sending me into madness…

Been wracking my brain on this one for no less than 4 hours.

If anyone can help, I’d be eternally grateful.

I have an ‘Edit Listing’ page on my site for users to login to and edit parts that are dynamically displayed, then submit to make changes.
The following is condensed, but you get the idea. All other parts of form(title,description) all update ok in my sql table, but not this ?

[code=php]<?
$areas = $_POST[‘area’][$i];

$query = “UPDATE listings SET area=’$areas’ WHERE id=’$id’ AND client_id=’$user_id'”;
$result = mysql_query($query);

echo ‘<select name=”area” size=”1″>
<option></option>
‘.”n”;

$areas = array(‘City Centre’,’Glasgow South’,’Glasgow West’,’Glasgow East’,’Glasgow North’);

$tempL = count($areas);
for ($i = 0; $i < $tempL; $i++) {
if ($areas[$i] == $row[33])
{
echo “<option value=$i selected=”selected”>”.$areas[$i].”</option>”;
}
else
{
echo “<option value=$i>”.$areas[$i].”</option>”;
}
}
echo ‘</select></p>’;
?>[/code]

Now $row33(it’s a huuuuuge sql query) is the name of the value in my ‘area’ table which stores the ‘NAME’ e.g. ‘City Centre’.

When I first load the page, it displays the correct name(e.g ‘City Centre’) in the select menu(as chosen previously by the user), but on submission it stores the value as ‘0’, instead of either 1,2,3 or 4 ?
So, upon form submission it sets the ‘area’ value equal to ‘0’, rather than say ‘1’(which relates to ‘City Centre’) or ‘2’(which relates to ‘Glasgow South’).

Any help guys?

Happy to explain further if I haven’t made sense.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@invisionauthorMar 05.2008 — Got it working ?

I tried $areas = $_POST['area']; instead of $areas = $_POST['area'][$i];

Thank you nemonoman ?
×

Success!

Help @invision 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...