Page 1 of 1

select box value not updated.

Posted: Wed Jun 06, 2012 9:10 pm
by nirosha
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());

Re: select box value not updated.

Posted: Wed Jun 06, 2012 11:17 pm
by pbs
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>

Re: select box value not updated.

Posted: Thu Jun 07, 2012 11:53 am
by nirosha
Thank you pbs. I've totally missed the value from php part. :banghead: