title: while / foreach loop updating quantity in mySQL
body: <p>I have a script where I am getting shopping cart IDs and then lowering the availability count based on if the product has been paid. Each cart might contain 1 or 10 products, so it's got to happen for each of the items. When someone pays (confirmed via PayPal IPN), I am running:</p>
  
  <pre><code>// we set the cart id, 12345 in this case
  $cart_id = '12345'
  
  // we get the buyer ID
  $buyer_id = $db-&gt;get_sql_field("SELECT buyer_id FROM db_carts WHERE sc_id='" . $cart_id . "'", "buyer_id");
  
  // we get the products.
  $sql_select_cart = $db-&gt;query("SELECT item_id, quantity FROM db_shopping_carts_items WHERE sc_id='" . $cart_id . "'");
  
  while ($cart_details = $db-&gt;fetch_array($sql_select_cart))
          {
  
              //
              foreach ($cart_details as $key =&gt; $item_details)
              {
                  if ($item_details['quantity']&lt;='100')
                  {
                      $db-&gt;query("UPDATE db_products SET quantity=quantity-" . $item_details['quantity'] . 
                      " WHERE product_id='" . $item_details['item_id'] . "'");
                  }
              }
              //
  
          }
  </code></pre>
  
  <p>However, nothing seems to happen and neither am I getting an error message. What am I doing wrong here?</p>