My question is regarding the ability to update a certain record by choosing a single record from a table and going to that selected record in another page with the full data. I know I would have to create another file with all of the input fields I need, but my question is how do I get there and send over the data info that I selected, then how do I echo out that information and allow the record to be updated?
Let's say I have a table called "Products" that looks like this:
ID Name Amount
1 Shoes $10 Edit
2 Hats $5 Edit
If I click the "Edit" Button next to "Shoes" I want to go to a different page which allows me to edit all of the information for that record selected.
<form method="POST">
<input name="first" placeholder="First Name">
<input name="last" placeholder="Last Name">
<input name="product" placeholder="Product">
<button name="add" type="submit">Add</button>
</form>
</div>
<hr>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$stmt = $dbc->query("SELECT * FROM users");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while($row = $stmt->fetch()) {
?>
<form method="POST">
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['amount'];?></td>
<td><button name="edit" type="submit">Edit</button></td>
</tr>
</form>
<?php } ?>
</tbody>