•
•
•
•
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,967 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,741 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: 2838 | Replies: 2 | Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 183
Reputation:
Rep Power: 2
Solved Threads: 5
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['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 "<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>";
1st page
$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 "<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>";
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 Syntax (Toggle Plain Text)
<?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>
Last edited by buddylee17 : Nov 26th, 2007 at 5:06 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- pass the value to the text box (JavaScript / DHTML / AJAX)
- text box validataion (ASP.NET)
- auto completion of the text box from previous entered values (JavaScript / DHTML / AJAX)
- help for auto complete text box (ASP.NET)
- a default value in a text box (Visual Basic 4 / 5 / 6)
- Help me pull values to a text box (C)
- Problem in getting values of a text area by row and column wise (ASP)
- Text box population from DBgrid. HELP!! (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: online projects
- Next Thread: Would someone please check my site definitions?


Linear Mode