DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   how to insert database value to a textbox (http://www.daniweb.com/forums/thread115306.html)

zidaine Mar 23rd, 2008 5:31 am
how to insert database value to a textbox
 
hi i'm a newbie in php, plz help me with this.
how can i put the value of my database to a textbox?
can u give me a sample code..
thx...

nav33n Mar 23rd, 2008 6:40 am
Re: how to insert database value to a textbox
 
http://www.w3schools.com/php/php_mysql_select.asp Check this. Instead of echoing $row['FirstName'] and $row['LastName'] in the example, assign it to a variable and use it as the 'value' of the textbox.
<input type="text" name="firstname" value="<?php echo $firstname; ?>"> 

zidaine Mar 24th, 2008 4:28 am
Re: how to insert database value to a textbox
 
Quote:

Originally Posted by nav33n (Post 567254)
http://www.w3schools.com/php/php_mysql_select.asp Check this. Instead of echoing $row['FirstName'] and $row['LastName'] in the example, assign it to a variable and use it as the 'value' of the textbox.
<input type="text" name="firstname" value="<?php echo $firstname; ?>"> 




thx nav33n. but how about textboxes inside a
<?php ?>
tags? do i have to echo
<input type="text" name="firstname" value="<?php echo $firstname; ?>">
?

nav33n Mar 24th, 2008 5:14 am
Re: how to insert database value to a textbox
 
textbox inside <?php tags ? Yep, you have to echo it. But this way.
echo "<input type=\"text\" name=\"name\" value=\"$firstname\">"; 

jino Mar 24th, 2008 8:06 am
Re: how to insert database value to a textbox
 
Or u can write as

echo "<input type='text' name='name' value='$firstname'>";


All times are GMT -4. The time now is 5:55 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC