i have a form which will display the details in a table,when edit button is clicked all the content in the table should come in a form(ie inside the textboxes)..so that the user can edit and save the content again in the database.
1st page
$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 "<tr><td>Name</td><td> $line[0]</td></tr>";
print "<tr><td>age</td><td> $line[1]</td></tr>";

}
echo "</table>";


mysql_close($link);
?>
<form method="post" action="red11.php">
<input type="submit" name="submit" value="submit">
</form>


2nd page
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);

echo '<input type="text" value="'.$_get[name].'">';
?>
Age<input type="text" name="age">
<input type="submit" name="update" value="update">
<?
}
echo "</table>";

Recommended Answers

All 3 Replies

Is this meant to be a question or are you simply showing that you can do this?

In order to submit variables to the second page, you'll have to find a way to get them inside of the form on the first page. On the first page, your form is empty, i.e. no variables actually make it in between the <form> and </form> tags. Use your loop to populate the table rows and columns. Then echo or print them into the form similar to this:

<?php
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['name'];
$result=mysql_query("SELECT * FROM hi where name='$line'");
$content="";
while($row=mysql_fetch_array($result))
{
$strRow=$row[0];
$content .="<tr><td>Name</td><td><input type="text" name="Name" value="$strRow[0]" /> </td></tr> \n";
$content .="<tr><td>age</td><td> <input type="text" name="Age" value="$strRow[1]" /></td></tr>";
}
?>
<html>
<body>
<form method="post" action="red11.php">
<table width='50%' border='1'>
<?php echo $content;?>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

when i select id from drop down list box then the other value of same table like subject show in txt box

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.