Hi,
I am trying to get some info form my database.
I want to see if there is an entry with a certain product_id that also has another column marked as 1.
I want to display the number of rows that contain that combination.
I have tried a few different ways, none of which work. However they are below.
$checkDuplicate = "SELECT * FROM '".$user."' WHERE product_id = '".$id."'";
foreach ($conn->query($checkDuplicate) as $row) {
$inCart = $row['in_cart'];
}
$isCartSql = "SELECT COUNT(*) FROM '".$user."' WHERE product_id = '".$id."' AND in_cart = '1'";
$isCart = $conn->prepare($isCartSql);
$isCart->execute();
$inCart = $isCart->rowCount();
with the foreach one, I am getting this error:
Warning: Invalid argument supplied for foreach() in ... on line 3
and the other one, just doesn't give me anything. Nothing is outputted, or if it is, I have no idea where or how to catch it.
Thankyou for your help.
QWaz