I need the form to auntomatically display whatever info is obtained from the database for me to edit......
I have tried but i still face problem.... can someone help me check??
$dbvalue= {$row['country']};
<select name="cnty">
<OPTION VALUE="">None
<OPTION VALUE="Afghanistan" <?php if (isset($dbvalue) && $dbvalue == "Afghanistan") echo 'selected="selected"'; ?>>Afghanistan
<OPTION VALUE="Albania" <?php if (isset($dbvalue) && $dbvalue == "Albania") echo 'selected="selected"'; ?>>Albania
Yah and one more problem i face.... why is it that when my edit form obtain info from the database it omits everything after a space??
eg name in database : Johnny Lim
display in form : Johnny
help required
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
Try this instead:
<OPTION VALUE="Albania" <?php if (isset($dbvalue) && $dbvalue == "Albania") echo 'SELECTED'; ?>>Albania
Also, for your second question, make sure you are putting quotes around the value.
Like, you are probably doing this:
<input type="text" name="firstname" value=<?php echo $dbvalue ?>>
Change it to:
<input type="text" name="firstname" value="<?php echo $dbvalue ?>">
<OPTION VALUE="Albania" <?php if (isset($dbvalue) && $dbvalue == "Albania") echo 'SELECTED'; ?>>Albania
Also, for your second question, make sure you are putting quotes around the value.
Like, you are probably doing this:
<input type="text" name="firstname" value=<?php echo $dbvalue ?>>
Change it to:
<input type="text" name="firstname" value="<?php echo $dbvalue ?>">