Hi Guys
I wonder if you could help me?
I want to incorporate a drop down listbox into an existing webpage header.
This is the listbox form code I have built into the existing header template (header.tmp.php) which I think is ok :
<form action="loc.php" method="post" >
<input type="hidden" name="option" value="loc_search">
<td><select name="user_loc" onchange="this.form.submit();">
<option value="500" <? echo ($user_details['user_loc']=='A') ? 'selected' : ''; ?>><?=MSG_LOC_A;?></option>
<option value="50" <? echo ($user_details['user_loc']=='B') ? 'selected' : ''; ?>><?=MSG_LOC_B;?></option>
<option value="75" <? echo ($user_details['user_loc']=='C') ? 'selected' : ''; ?>><?=MSG_LOC_C;?></option>
<option value="100" <? echo ($user_details['user_loc']=='D') ? 'selected' : ''; ?>><?=MSG_LOC_D;?></option>
</select></td>
</form>
The listbox should post the users location to the database and hold that location until the user decides he wants to change it. If the above code is ok for the header form I am stuck with the code needed to process the information collected (loc.php)
My current code for loc.php is as follows but I suspect this is wrong.
$selected_loc = $_POST['user_loc'];
$update_sql_loc= $db->query("UPDATE " . DB_PREFIX . "users SET user_loc ='" . $selected_loc . "'WHERE user_id='" . $user_id . "'");
$get_loc = $db->get_sql_row("SELECT user_loc FROM " . DB_PREFIX . "users WHERE user_id='" . $user_id . "'");
$template->set('user_loc', $get_loc['user_loc']);
echo $template_output;
Just to confirm, the listbox form and loc.php basically need to collect the posted location from the header.tmp.php, send it to the database and then go back to the webpage with the new user location set and stored in the listbox as the new selection. Nothing else.
Any help would be very much appreciated.
Thanks in advance.
EJ