I am trying to insert the checkbox into the database using WHERE clause. The code redirects without any error. But it is not updating into the database. When i uncheck the checkbox, the row gets deleted without any issue for the id. It is just the INSERT i am having the issue. I cannot seems to find the problem here.
The code below works without using the WHERE clause. 
$bId = $_POST['fm_id']; // this is coming from the hidden input field
if (isset($_POST['fm_day_hid'], $_POST['fm_day'])) {
    $ckb = $_POST['fm_day'];
    for ($i = 0; $i < count($ckb); $i++){
        if(!empty($ckb)){
            $arrayMovies = $ckb[$i];
            $sql = "INSERT INTO checkbox_batchdays (cbx_days) 
            SELECT * FROM (SELECT '$arrayMovies') AS tmp WHERE NOT EXISTS 
            (SELECT cbx_days FROM checkbox_batchdays WHERE cbx_days = '$arrayMovies') 
            WHERE cbx_batchid='$bId'";
            $query = mysqli_query($con, $sql);
        }
    }
    foreach($_POST['fm_day_hid'] as $moviesHidden) {
        if(!in_array($moviesHidden, $_POST['fm_day'])){
            $sql = "DELETE FROM checkbox_batchdays 
            WHERE cbx_days='$moviesHidden' AND cbx_batchid = '$bId'";
            $query = mysqli_query($con, $sql);
        }
    }
}
else {
    $sql = "DELETE FROM checkbox_batchdays WHERE cbx_batchid = '$bId'";
    $query = mysqli_query($con, $sql);
}
if( $query ) {
    header("Location: ../../batches.php");
}
else {
    echo "Not Deleted!";
}
