Jump to content

Insert into one table and update another one


maziagha

Recommended Posts

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:
[code]
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);[/code]

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

So it should look like this:
[code]
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);[/code]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.