[php]if(mysqli_num_rows($res) == 0) {
$query =“INSERT INTO cart (sid,id_item,quantity) VALUES (’”.$_SESSION[‘username’]."’,".$id.",".$q.")";
}
else {
$query = “UPDATE cart SET quantity=quantity+”.$q." WHERE sid=’".$_SESSION[‘username’]."’ AND id_item=".$id;
}[/php]
I’m trying to restrict the quantity of an item, how do I go about this?
Are YOU joking? What do you want to restrict? Do you mean you want to limit the maximum quantity?
if ($Q > 10) $Q=10;
Something like that would limit it to 10 if that was your question.
If you were asking to limit the total that is in your cart, you would have to first query the cart to get the
current value of the quantity and then adjust the new value depending on that already stored value.
Lastly, a title like yours does not help anyone to help you. You should have put CART quantities or some
other words in the title to help us. Some programmers here have a lot of cart experience but, might not
even look at your post because of it’s title!