help required

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
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

help required

Post by dakkonz »

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
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

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 ?>">
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Did you do any formatting to the name before it was inserted? Post the code that extracts the partial name...
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

Post by dakkonz »

oh i had it settled already...thanks a million :D
Post Reply