jeudi 25 janvier 2018

DELETE FROM if checkbox is unchecked

i use this php script to update the database if a checkbox is checked:

    if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['update'] == "yes")  {

    $checkboxDkw = $_POST['DKW'];

    for ($i=0; $i<sizeof($checkboxDkw); $i++)
    {
        $query="INSERT INTO afg_planningen (filiaal_nr, week_nr, afdeling) VALUES ('".$_POST['filiaal_nr']."', '" . $checkboxDkw[$i] . "', '1')";     

        if(mysql_errno() != 1062)   {

        mysql_query($query) or die (log_error($query));
        }
        else    {
           $query="DELETE FROM afg_planningen WHERE filiaal_nr = '".$_POST['filiaal_nr']."'
                                                AND week_nr = '" . $checkboxDkw[$i] . "',
                                                AND afdeling = '1')";     
         mysql_query($query) or die (log_error($query));
    }

    }
echo "Complete";

}

But i also want to delete all entry's where te checkbox is unchecked. How can i do this? Because the date is in an array.




Aucun commentaire:

Enregistrer un commentaire