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>’;
?>
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.