jeudi 1 février 2018

Clicking the checkbox and changing database Boolean value in php

I have my database connected through my code, the column I'm trying to change is called "Sent". The checkbox is inside a table so it's more organized. I'm trying to do it so when the user clicks the checkbox the database gets automatically changed to 1 if its checked and to 0 if its unchecked. The variable conn is the connection I've made. Here's what I have:

<?php

    $execItems = $conn->query("SELECT Sent FROM Schools");

    while($infoItems = $execItems->fetch_array())
    {
        echo    "
                <tr>
                    <td><input type=\"checkbox\"".($infoItems['Sent']?' checked':'')."\" /></td>
                </tr>
                ";

    }
?>




Aucun commentaire:

Enregistrer un commentaire