Hey, I'm building a shopping cart and I'm having trouble getting the item quantities to update in the database. Everything else works right, the price totals are updated, I can pass the cart data over to PayPal, and everything else works great. Just not the quantity updates to the item databases.
These are the two functions I use:
function inventory() {
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '".GetCartId()."'");
$row = mysql_fetch_array($result);
$new_qty = $row['itemQty'] - $row['qty'];
}
function control($qty, $itemId) {
inventory();
mysql_query("UPDATE items SET itemQty = itemQty - $qty WHERE itemId = $itemId");
}
I call the control() function in a hidden field inside the PayPal button.
Can anybody help or recommend an alternate way of doing it? I'm running headlong into a wall here.
Thanks!