User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,579 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,435 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1899 | Replies: 4 | Solved
Reply
Join Date: Mar 2008
Location: Philippines
Posts: 3
Reputation: zidaine is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zidaine's Avatar
zidaine zidaine is offline Offline
Newbie Poster

Question how to insert database value to a textbox

  #1  
Mar 23rd, 2008
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...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: how to insert database value to a textbox

  #2  
Mar 23rd, 2008
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; ?>">
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Mar 2008
Location: Philippines
Posts: 3
Reputation: zidaine is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zidaine's Avatar
zidaine zidaine is offline Offline
Newbie Poster

Re: how to insert database value to a textbox

  #3  
Mar 24th, 2008
Originally Posted by nav33n View Post
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; ?>">?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: how to insert database value to a textbox

  #4  
Mar 24th, 2008
textbox inside <?php tags ? Yep, you have to echo it. But this way.
echo "<input type=\"text\" name=\"name\" value=\"$firstname\">";
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Feb 2008
Location: Cochin
Posts: 67
Reputation: jino is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
jino's Avatar
jino jino is offline Offline
Junior Poster in Training

Re: how to insert database value to a textbox

  #5  
Mar 24th, 2008
Or u can write as

  1. echo "<input type='text' name='name' value='$firstname'>";
Last edited by peter_budo : Mar 24th, 2008 at 7:43 am. Reason: Keep It Organized - please use [code] tags
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC