This is the function I use to query the data
public function MassDelete($POST){
$DB = new Database();
for ($i=0; $i < count($POST['delete-checkbox']); $i++) {
$productID = $POST['delete-checkbox'][$i];
$CID = ($DB->read("SELECT * FROM products WHERE id = $productID"));
$categoryName = $this->CategoryList[$CID[0]["category_id"]];
$productQuery = "DELETE * FROM products WHERE id = $productID";
$productData = ($DB->write($productQuery));
if($productData){
$categoryQuery = "DELETE * FROM $categoryName WHERE product_id = $productID";
$categoryData = ($DB->write($categoryQuery));
}
}
// header("Location:" . ROOT . "Home");
}
This is the DB->Write Method that I'm using
public function write($query, $data=[])
{
$db = $this->Connect();
if(count($data)==0){
$stm = $db->query($query);
$check = 0;
if($stm){
$check = 1;
}
}else{
$stm = $db->prepare($query);
$check = $stm->execute($data);
}
if($check)
{
return true;
}else{
return false;
}
}
This line of code works just fine and I'm able to fetch the data, so I don't understand why the DELETE query doesn't work
$CID = ($DB->read("SELECT * FROM products WHERE id = $productID"));