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
<?php
echo "<form name=\"tableView\" method=\"post\" action=\"tableRowEdit.php\">";
echo <table width=\"750\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">";
$result = mysqli_query($connect, "SELECT * FROM $db order by Age");
while ($row = mysqli_fetch_array($result)) {
echo"<tr align=\"center\">";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "<td>" . $row['Location'] . "</td>";
echo "<td><input type='submit' value='Edit' /></td>";
echo "<input type='hidden' name='id' value='" . $row['id'] . "' />";
echo "</tr>";
}
echo "</table>";
echo "</form>";
?>
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>";
?>
]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.










