Jump to content

Updating database depending on form results


unplugged_web

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...