0

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.

3
Contributors
4
Replies
9
Views
10 Years
Discussion Span
Last Post by lydia21
0

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; ?>">

works fine for me.

0

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; ?>"> 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;
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;
$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);
?>

0

On page 2,

print 'Name: <input type="text" name="name" value="'.$line[0].'" />';

This wont pass to page 3 unless it's between <form> and </form> though.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.