mercredi 27 juillet 2016

how can I disabled the checkbox and updated in database php

How can I disabled the checkbox and updated in the db? I mean, if the value is 1 the checkbox is checked and updated in the db, but if I unchecked the checkbox i want that in my db to be updated with 0.

   <input type="checkbox"  name="check" value = "$watered" <?php echo $check;?> OnClick="doAction(<?php echo $id;?>);" > </td>

the function doAction who doesn't matter and the file where is gone:

  if (isset($_GET['id'])) {

        $id = $_GET['id'];
        $query = mysql_query("update plants set watered = 1 where id = $id ");
        if ($query){
            echo "you have watered the plants.";
        }else {
            echo "you cannot watered the plants";
        }
    }else{
        echo "vvvvvvvvv";
}




Aucun commentaire:

Enregistrer un commentaire