$delete = mysqli_query($connection,"SELECT Quantity FROM Books WHERE (ID='$idB' AND Quantity < 1)");
if($delete){
$delete_run = mysqli_query($connection,"DELETE FROM Books WHERE ID='$idB'");
echo "<script>alert('Book successfully deleted!')</script>";
}else{
$remove= mysqli_query($connection, "UPDATE Books SET Quantity = Quantity - $quantityB WHERE (ID='$idB' AND Quantity > 0)");
if($remove){
echo "<script>alert('Book successfully removed!')</script>";
}
}
}
My goal here is to delete a data from a table only if the quantity reaches zero and I am having trouble on how to implement that idea what I have so far is just deleting the data with whatever ID was input by the user. $idB and $quantityB are the variables that I used to store user input. Need help