I use select box to select title of the person in html. When I save value for the first time in mysql table it works fine. When I retrieve the value to the select box from mysql and update without changing the select box value it does not updated in the table. But if I change the select box value and update then it updated in the table. Any help please.
select box:
<select name="lsttitle" size="1" id="lsttitle" title="">
<option value="" Selected="Selected"><?php echo $title;?></option>
<option value="Mr.">Mr.</option>
<option value="Ms.">Ms.</option>
</select>
update query:
mysql_query("UPDATE tblClient SET ClientName='$_POST[txtClientName]', Date='$_POST[txtDate]', Title='$_POST[lsttitle]', ClientAddress='$_POST[txtAddress]', NICNo='$_POST[txtNICNo]', ContactNo1='$_POST[txtContact1]', ContactNo2='$_POST[txtContact2]' WHERE LMNo=$LMNo") or die(mysql_error());
select box value not updated.
Moderator: General Moderators
Re: select box value not updated.
You have just set text in the select box, set value as well
use this select box
select box:
<select name="lsttitle" size="1" id="lsttitle" title="">
<option value="<?php echo $title;?>" Selected="Selected"><?php echo $title;?></option>
<option value="Mr.">Mr.</option>
<option value="Ms.">Ms.</option>
</select>
use this select box
select box:
<select name="lsttitle" size="1" id="lsttitle" title="">
<option value="<?php echo $title;?>" Selected="Selected"><?php echo $title;?></option>
<option value="Mr.">Mr.</option>
<option value="Ms.">Ms.</option>
</select>
Re: select box value not updated.
Thank you pbs. I've totally missed the value from php part. 