-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
SQL Server Management Studio 22.7 brings "What's New" page, T-SQL formatting, and lots more
By Usama Jawad96,
- 3 replies
- 0 views
-
- 4 replies
- 0 views
-
Good news: JetBrains makes another IDE free for non-commercial use
By David Uzondu,
- 0 replies
- 0 views
-
AI's impact on programming language popularity revealed
By zikalify,
- ieee
- programming languages
- (and 7 more)
- 3 replies
- 0 views
-
Microsoft reveals plans for SQL Server Management Studio
By Usama Jawad96,
- microsoft
- sql server management studio
- (and 6 more)
- 12 replies
- 0 views
-
Question
vas
Have a db table with:
id | Name | Age | Location
----------------------------------------
1 | jim | 67 | AL
2 | sam | 23 | CA
3
4..... etc
tableView.php that displays a table of all the sql rows. At the end of each table row I have an Edit button. The goal of clicking the button would be it then goes to tableRowEdit.php where it displays only the db row that was clicked on in editable text fields.
tableView.php snippet
tableRowEdit.php snippet
<?
$posted_id = $_POST['id'];
echo $posted_id;
$result = mysqli_query($connect, "SELECT * FROM $db where id='" . $posted_id . "'") or die ("Error in query: $result");
if ($row = mysqli_fetch_array($result)) {
echo "<form name='tableRowEdit' method='post' action='tableUpdate.php'>\n";
echo "<table width=\"750\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">";
echo "<tr align=\"center\">";
echo "<td><input type=\"text\" name=\"tre_name\" value=\"" . $row['Name'] . "\" /></td>";
echo "<td><input type=\"text\" name=\"tre_age\" value=\"" . $row['Age'] . "\" /></td>";
echo "<td><input type=\"text\" name=\"tre_location\" value=\"" . $row['Location'] . "\" /></td>";
echo "<td><input type='submit' value='Submit' /></td>";
echo "<input type='hidden' name='id' value='" . $row['id'] . "' />";
echo "</tr>";
}
echo "</table>";
echo "</form>";
?>
[/CODE]
]
And from there I'm going to have the tableUpdate.php to send the update query sql commands. Which I haven't started yet due to my problem.
Problem is clicking the edit button is only displaying the last row's data, I am unable to get it to only pass the row that was clicked on. Has to be something simple that my tired eyes are simply not seeing.
Any hints would be appreciated.
Link to comment
https://www.neowin.net/forum/topic/1059642-passing-_post-data-in-a-form/Share on other sites
5 answers to this question
Recommended Posts