jeudi 23 juin 2016

How to update MYSQL table from HTML form with single column of checkboxes

I have a MYSQL table named 'orders' that I want to update from a single column of checkboxes in an html form. The code within the form is " I've looked around for a long time to see how I could submit this form and update my database with this single line of code. In other words, the column of checkboxes consists only of this code block, but there is a checkbox at the end of each row. I know that only the checked boxes will be returned in the $_POST['completed'] array. How does one go about updating a mysql table with only one such code block? The update code is this: update = "UPDATE orders SET completed='$completed' WHERE completed=0;"; //IF THIS UPDATE WORKED, I THINK IT WOULD UPDATE THE WHOLE TABLE, WHICH I DON'T WANT! Then $res = mysqli_query($db, $sql) or die(mysql_error()); //update or error




Aucun commentaire:

Enregistrer un commentaire