I’ve got a huge 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.