I have a 3 tables: product, category and product_category. I am creating a form who edit(insert/delete) categories for a product. I am trying to insert an array of checkboxes in a relation table.
<input name="category[]" type="checkbox" value="<?php echo $cat->slug; ?>">
I know how to insert the checked values, but I don't know how to delete the unchecked ones.
$category = $_POST['category'];
for ($i = 0; $i < count($category); $i++) {
    if (!empty($category)) {
        $verifycategory = BD::conn()->prepare("SELECT * FROM `product_category` WHERE id_product = ? AND id_category = ?");
        $verifycategory->execute(array($id_prod, $category[$i]));
        if ($verifycategory->rowCount() == 0) {
            $anm = BD::conn()->prepare("INSERT INTO product_category(id_product, id_category) VALUES(?,?)");
            $anm->execute(array($id_prod, $category[$i]));
        }
    }
}