unplugged_web Posted April 8, 2015 Share Posted April 8, 2015 I've got a huge (pre-populated) form that it used for keep track of stock. The problem is that I've added a field for stock for the shop and want to update the online stock depending on which product was changed. The problem is that people won't be changing one product at a time but could be change 10, 20, 100 or whatever so I ned to make sure that the right product is updated. Also the number could go up as well as down and should also adjust the online stock depending on what entered in the shop field for that product. So far it works if one product has it's shop stock increased. It doesn't work if it decreases or if multiple products are changed. This is what I've got at the moment: if( isset( $_POST['shop-1-'.$row['id']] ) && ctype_digit( $_POST['shop-1-'.$row['id']] ) ) {if ( $row['shop'] > $_POST['shop-1-'.$row['id']] ) { // checks if the shop stock is higher $query="update stock set online=online+".$_POST['shop-1-'.$row['id']].",shop=".$_POST['shop-1-'.$row['id']].",shop_date=".time()." where id=".$row['id']; dbUpdate( $query,"dbLinkInt" );} elseif ( $row['shop'] < $_POST['shop-1-'.$row['id']] ) { // checks if the shop stock is lower $query="update stock set online=online-".$_POST['shop-1-'.$row['id']].",shop=".$_POST['shop-1-'.$row['id']].",shop_date=".time()." where id=".$row['id']; dbUpdate( $query,"dbLinkInt" );} elseif ( $row['shop'] == $_POST['shop-1-'.$row['id']] ) { // checks if the shop stock doesn't change }} Thanks in advanced for any help with this. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 8, 2015 Share Posted April 8, 2015 What happens when you run that? What exactly is not working? Link to comment Share on other sites More sharing options...
unplugged_web Posted April 9, 2015 Author Share Posted April 9, 2015 What happens when you run that? What exactly is not working? If the number is zero then nothing happens at all. If the number is lower than what's there but not zero then it deducts it from the online stock again (instead of adding it back the difference) Link to comment Share on other sites More sharing options...
unplugged_web Posted April 9, 2015 Author Share Posted April 9, 2015 I decided not to do it this way Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now