Having a table generated from MySQL datas, each row has a field containing multiple forms.
I need to put a checkbox on the first field of each row, containing the unique ID, and later I need to pass the multiple checkbox values by POST with a button located outside the table.
How do I obtain that, when nested forms cannot be done?
Here's my code:
<!-- This button needs to be outside of the table -->
<button type="submit" form="selected_checkboxes">Send checked boxes</button>
<table>
<thead>
<tr>
<th>Select</th>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- If I put the form there, for the selected checkbox, it won't work, because the other forms
are nested inside the table -->
<form action="page.php" method="POST" name="selected_checkboxes"> <!-- THIS WON'T WORK -->
<?php
$db = $conn->prepare('SELECT * FROM accounts WHERE name = ? ORDER BY id DESC');
$db->bind_param('i', $name);
if (!$db->execute()) die('Error while fetching accounts: '. $conn->error);
$res = $db->get_result();
while ($data = $res->fetch_assoc()) {
$id = $data['id'];
$name = $data['name'];
echo '<tr>
<td><input type="checkbox" name="list[]" value="'.$id.'"></td>
<td>'.$name.'</td>
<td>
<form action="page.php" method="POST"><input type="hidden" name="id" value="'.$id.'" /><button type="submit" name="action1">Send</button></form>
<form action="page.php" method="POST"><input type="hidden" name="id" value="'.$id.'" /><button type="submit" name="action2">Archive</button></form>
</td>
</tr>
}
?>
</form> <!-- TO CLOSE THE NOT WORKING FORM -->
</tbody>
</table>
How would you solve this problem?