select box value not updated.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nirosha
Forum Newbie
Posts: 5
Joined: Mon Feb 20, 2012 10:56 pm

select box value not updated.

Post 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());
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: select box value not updated.

Post 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>
nirosha
Forum Newbie
Posts: 5
Joined: Mon Feb 20, 2012 10:56 pm

Re: select box value not updated.

Post by nirosha »

Thank you pbs. I've totally missed the value from php part. :banghead:
Post Reply