Jump to content


Photo

Insert into one table and update another one


  • Please log in to reply
1 reply to this topic

#1 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 11 September 2006 - 09:45 AM

Hi!
I'm working on a webshop and everything works fine. Now there is only one thing left and i can't get it working.
In the code below i'm Updating the products the customer is buying into the Quantity table(works good) but at the same time i want to remove the quantity of the product from the stock list that contains sizes of the products.

Here is the part that I updatethe products in quantity table:
for ($i = 0; $i < $numItem; $i++) {
$sql = "UPDATE tbl_product 
SET pd_qty = pd_qty - {$cartContent[$i]['ct_qty']}
WHERE pd_id = {$cartContent[$i]['pd_id']}";
$result = dbQuery($sql);

Here is the code to remove the specific sizes from the stock:
$query = "UPDATE productquantity SET Quantity = Quantity - {$cartContent[$i]['ct_qty']}
WHERE QProdID = {$cartContent[$i]['pd_id']} AND QSizeID = {$cartContent[$i]['ct_size_n']}";

So it should look like this:
for ($i = 0; $i < $numItem; $i++) {
$sql = "UPDATE tbl_product 
SET pd_qty = pd_qty - {$cartContent[$i]['ct_qty']}
WHERE pd_id = {$cartContent[$i]['pd_id']}";
$query = "UPDATE productquantity SET Quantity = Quantity - {$cartContent[$i]['ct_qty']}
WHERE QProdID = {$cartContent[$i]['pd_id']} AND QSizeID = {$cartContent[$i]['ct_size_n']}";
$result = dbQuery($sql,$query);

But this wont work. Can anyone pls help me???

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 September 2006 - 02:09 PM

What is it that's not working about it?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users