Jump to content

get single value from query


intro9

Recommended Posts

Im' a green beginner here and I'm having a small problem I'm sure somebody can solve fairly quickly. I am trying to write a few lines of code that removes as many items from my database as are in the persons shopping cart. I just can't get the script to get the quantity value out of the cart database.

 

 

 

$quantity = mysql_query("select qty from cart where cookieId = '" . GetCartId() . "' and itemId");

 

mysql_query("update items set stockcount = stockcount - '" . $quantity . "' where itemId = $itemId");

 

 

 

I want to update the items table to decrease the stockcount by the amount the person purchased, aka the value in the qty field in the persons cart.

 

I want the $quantity variable to be equal to the qty of the current item in my cart. database. as shown below. I know I am taking the full row in my first line of code, which is COMPLETELY wrong, but what is the correct method of getting that single value from the cart table, the qty value into the $quantity variable so I can use it in my stockcount deduction?

 

Thanks in advance!

 

Frank

Link to comment
Share on other sites

Thank you Soooooo much, that worked great! You know, I tried something similar a few times, but I was just a hair off on both previous attempts. Good to know I was on the right track tho, and thanks for the lightning quick response. I'm very thankful!

 

Sincerely,

Frank

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.