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 455,974 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,766 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: 2311 | Replies: 4 | Solved
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

get database values to my textbox

  #1  
Nov 26th, 2007
hi
how to get my database values to my textbox....
i want to update my database content.in order to do that i want to display the existing content in a textbox so that the user can change the content and click update to update the content in the db.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Posts: 23
Reputation: ezb is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
ezb ezb is offline Offline
Newbie Poster

Re: get database values to my textbox

  #2  
Nov 27th, 2007
Assuming you know how to pull things from the database already, you should be looking at something like this
<input name="box1" type="text" id="box1" value="<? echo $rows['ENTER NAME']; ?>">
works fine for me.
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: get database values to my textbox

  #3  
Nov 27th, 2007
hi,
i have three pages.In the third page....i want the textbox to get the data base content in it but it is not working..i tried <input type="text" id="name" value="<? echo $line['0']; ?>"> but it is not working for me.i want to know wants wrong with my code
1st page
<?php
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$result=mysql_query("SELECT name FROM hi");
print "name";
for ($i = 0; $i < mysql_num_rows($result); ++$i)
{
$line = mysql_fetch_row($result);
rint "<a href='king.php?name=".$line[0]."'>".$line[0]."";
}
mysql_close($link);
?>

2nd page
<?php
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['name'];
echo "<table width='50%' border='1'>";
$result=mysql_query("SELECT * FROM hi where name='$line'");
for ($i = 0; $i < 1; ++$i)
{ $line = mysql_fetch_row($result);
print "Name $line[0]";
}
echo "</table>";
mysql_close($link);
?>
<form method="post" action="red11.php">
<input type="button" name="edit" value="edit">
</form>


3rd page
<?php
$hostname = "localhost";
$username = "splendor_lydia";
$password = "jesus";
$dbid = "splendor_samp";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['name'];
$result=mysql_query("SELECT name,age FROM hi where name=$line ");
for ($i = 0; $i < mysql_num_rows($result); ++$i)
{
$line = mysql_fetch_row($result);
print " Name $line[0] ";
}
mysql_close($link);
?>
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 416
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 3
Solved Threads: 81
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro in Training

Re: get database values to my textbox

  #4  
Nov 27th, 2007
On page 2,
  1. print 'Name: <input type="text" name="name" value="'.$line[0].'" />';
This wont pass to page 3 unless it's between <form> and </form> though.
Last edited by buddylee17 : Nov 27th, 2007 at 10:51 am.
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: get database values to my textbox

  #5  
Nov 28th, 2007
thanks it is working.
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 9:17 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC