tobimichigan Posted March 21, 2010 Share Posted March 21, 2010 Hello Code Gurus, Please I am trying to write a web app that keeps track of incoming stocks for products. Lets assume a product x. In Mysql exits in the Product Table s/n name quantity 1 x 6 Now, I want to add additional quanity of 5 to the exisiting product to make a total of 11. <?php include ("cn.php"); $select=mysql_query("select * from product); $row=mysql_fetch_array($select); $product=$row['product']; ?> I seem to be stuc here, don't know how to increment/decrement the stored quantities in the product table. Please someone kindly help. Quote Link to comment https://forums.phpfreaks.com/topic/196011-stock-keeping/ Share on other sites More sharing options...
sangoku Posted March 22, 2010 Share Posted March 22, 2010 Hello Code Gurus, Please I am trying to write a web app that keeps track of incoming stocks for products. Lets assume a product x. In Mysql exits in the Product Table s/n name quantity 1 x 6 Now, I want to add additional quanity of 5 to the exisiting product to make a total of 11. <?php include ("cn.php"); $select=mysql_query("select * from product); $row=mysql_fetch_array($select); $product=$row['product']; ?> I seem to be stuc here, don't know how to increment/decrement the stored quantities in the product table. Please someone kindly help. that one is fairly easy to do just doa select on the tabl as you were doing it before, do a fetch row and grab teh value you want to modify, then store the updated entry into the table again.... the plain stupid way which wastes 2 query's to do this stuff you can however do it with one... but you need to know trough knowledge of the scripting in mysql.... Quote Link to comment https://forums.phpfreaks.com/topic/196011-stock-keeping/#findComment-1030124 Share on other sites More sharing options...
ignace Posted March 22, 2010 Share Posted March 22, 2010 but you need to know trough knowledge of the scripting in mysql.... This secret knowledge sangoku is referring to is the query: UPDATE products SET quantity = quantity + 5 WHERE sn = 1 Depending on your sort of input there may be better methods Quote Link to comment https://forums.phpfreaks.com/topic/196011-stock-keeping/#findComment-1030134 Share on other sites More sharing options...
sangoku Posted March 22, 2010 Share Posted March 22, 2010 but you need to know trough knowledge of the scripting in mysql.... This secret knowledge sangoku is referring to is the query: UPDATE products SET quantity = quantity + 5 WHERE sn = 1 Depending on your sort of input there may be better methods LoL Not this one i was thinking if he needs to add a SQL cproc scrpit which would take the values and update them.... When the 5 is a variable XD Quote Link to comment https://forums.phpfreaks.com/topic/196011-stock-keeping/#findComment-1030148 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.