I need a form that allows a user to edit data from an SQL database.
The main page of my form contains a table where any available data is shown and, also, there are edit and delete options available. Sample:
{
$row=mysql_fetch_array($result);
echo "<tr>";
echo "<td>".$row["name"]."</td>";
echo "<td>".$row["occuptation"]."</td>";
echo '<td><a href="edit.php"><img src="edit.png"/></a></td>';
echo '<td><a href="delete.php"><img src="delete.png"/></a></td>';
echo "</tr>";
}
When the user clicks the edit.png I need it to direct to edit.php where the data from the whole row selected (whichever row the user chooses to click edit or delete from) shows up in a form (like default values). I have no idea how to achieve this.
Any help is appreciated! Please tell me if i’m being confusing and I will try to explain further.
What you’ll want to do is include an identifier as a query string parameter in the edit and delete links:
(Of course, I’m assuming the name of your identifier. But you get the idea.)
This will tell those pages which record they should display. The pages would get the identifier with:
A few things you’ll want to consider:
$_GET["id"]before you try to do anything with it. Never assume it’s valid without checking.idvalue in the URL.