intro9 Posted October 19, 2005 Share Posted October 19, 2005 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 Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted October 19, 2005 Share Posted October 19, 2005 $result = mysql_query("select qty from cart where cookieId = '" . GetCartId() . "' and itemId"); // might have something wrong with your query as well $quantity = mysql_result($result,0,0); Quote Link to comment Share on other sites More sharing options...
intro9 Posted October 19, 2005 Author Share Posted October 19, 2005 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.