So, i want to get id from $_POST["id"]
when i push a button in a table
<form action="dosomething.php" method="post">
<td> <?php echo $row["id"]; ?> </td>
<td> <button>Do something</button> </td>
</form>
is that even possible?
thanks for any answers and help
CodePudding user response:
Yes it is.
You will need to set a hidden input somewhere inside your form tags, like :
<form action="dosomething.php" method="post">
<input type="hidden" name="id" value="<?= $row["id"]; ?>" />
<td> <?php echo $row["id"]; ?> </td>
<td> <button onclick="this.form.submit();">Do something</button> </td>
</form>
This is not an elegant code and you should probably consider using javascript, especially if you have a lot rows and buttons.