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???
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.