php - Adding a condition that would return subtracted values when going to a specific page -


how create condition automatically return or re-add values subtracted when moving specific page.

for example. bought 3 apples, 5 in inventory, 3 automatically deducted inventory after pressing checkout.

however, user cancels order , value made still 2, though order cancelled,

what fix problem?

here code, , triggers when user presses checkout , goes page. kind of automatic, if can fix better one, more thanks. hehe.

// these codes automatically deduct quantity  available inventory when going page.             $qry = "update inventory                      set prod_quantity = prod_quantity - $q                      prod_id = '$pid'";             $result = @mysql_query($qry); 

how create condition return subtracted values inventory?

$q quantity ordered user. $pid product id.

thank much. hope guys can me.

after have subtracted value, have add in case when user cancels this:

// these codes automatically deduct quantity  available inventory when going page.             $qry = "update inventory                      set prod_quantity = prod_quantity + $q                      prod_id = '$pid'";             $result = @mysql_query($qry); 

but believe should update value when order committed. might want use transaction , should protect against sql injection.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -