Forum Moderators: coopster

Message Too Old, No Replies

How To Adjust stock quantities when sold

In a MYSQL databse

         

curlykarl

2:05 pm on Dec 17, 2004 (gmt 0)

10+ Year Member



Hi all

I’m building a site with live stock figures on, where account customers can order online and the order goes into a database, which someone can then retrieve at a later point. But I don’t know the correct formula to minus the ordered amount off the original quantity, I know how to store the details of the order in the database but not how to make the database update the quantity.

Any pointers would be appreciated.

Thanks

Karl

dreamcatcher

2:37 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi curlykarl,

This should work fine:

UPDATE table SET quantity=(quantity-1) WHERE id = 'productID'

dc

curlykarl

2:48 pm on Dec 17, 2004 (gmt 0)

10+ Year Member



Hi Dc,

Would this still work if they order more than 1 qty?

Thanks

Karl :)

dkin

5:13 pm on Dec 17, 2004 (gmt 0)

10+ Year Member



for that just insert $quantity where the 1 is

dreamcatcher

12:39 am on Dec 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks dkin. Yes, just insert the value you want to subtrack as a variable where the 1 is.