I need to catch the event when the checkboxes have been pressed (they can be inserted as many as possible into the HTML table by a cycle), and put its value in the MySQL table. So the form itself (removed too much):
<form name="new_form" action="/admin/osvega_test" method="POST"> <input class="my_button" type="submit" name="upload_submit" value="save" style="width: 200px"/> <table style="width: 1000;" id="activeTable" class="editableTable" overflow = "scroll"> <thead class="t_hdr"> <tr class="header"> <td><b>ID</b></td> <td><b>Печать</b></td> </tr> </thead> <tbody> <?php $i = 0; while ($row = $Result->fetch_assoc()) { $i++; ?> <tr id="z_<?=$i?>"> <td name = "post_id"><?=$row['id']?></td> <td> <input type="checkbox" name="stamp[<?=$row['id']?>]" value="<?=$row['stamp']?>" <? if($row['stamp'] == 1)echo $check ?> id="chkbox" > </td> </tr> <? } ?> </tbody> </table> </form> This is what the handler code looks like:
<?php foreach ($_POST['stamp'] as $id => $value) { if (isset($_POST['stamp'])){ $value = 1; $Database->query("UPDATE `izgotoviteli` SET stamp = $value WHERE id = $id"); } else{ $value = 0; $Database->query("UPDATE `izgotoviteli` SET stamp = $value WHERE id = $id"); } } ?> That is, if I tick and press the submit button, they are saved in the database with the value 1 (tinyint (1)), everything works here. It is necessary that the removal of a tick is also tracked (although it should) and 0 is entered into the database when it is removed.