Good day to all, help solve this problem, how do I put the checkbox in the database depending on if it checks 1, if not then 0, but you need to put it in that line in the database where it was checked on the site, in general I deduce checkboxes
<?php while ($row=$result->fetch_assoc()) { echo "<tr class='bordertr'><td>".$i++."</td><td>"."<form class='formch'><input type='checkbox' name='{$row['id']}' class='checkord' value='{$row['tocorrob']}'><label for='check1'>не принят</label></form>"."</td>"</tr>"; } ?> Ajax request
$('.checkord').on('change', function(){ var sendData = $(this).closest('.formch').serialize(); $.ajax({ url: 'formcheck.php', type: 'POST', data: sendData, success: function(data){ alert(data); // заменить на нужное } }); }); and the formcheck.php handler itself
<?php require_once 'dbconnect.php'; isset($_POST['check']) ? $checked = 1:$checked = 0; $result = $conn -> query ("UPDATE vacanciestbl SET tocorrob='$checked' WHERE id ='$id'"); ?>