anser316 Posted April 28, 2008 Share Posted April 28, 2008 this is stored inside the while loop while ($itemquan>0) { $itemquan=$itemquan-$stock;} how can i get the new itemquan into the one in brackets i.e. while (5>0) { 4=5-1;} and then while (4>0) { 3=4-1;} I get the error Fatal error: Maximum execution time of 30 seconds exceeded in ... how can i get the $itemquan to change? Link to comment https://forums.phpfreaks.com/topic/103263-decrement/ Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 it works just fine (according to this example script): <?php $itemquan = 10; $stock = 1; while ($itemquan>0) { $itemquan=$itemquan-$stock; print $itemquan; } Link to comment https://forums.phpfreaks.com/topic/103263-decrement/#findComment-528884 Share on other sites More sharing options...
anser316 Posted April 28, 2008 Author Share Posted April 28, 2008 While ($itemquan>0) { // run while quantity is not 0 $stock=$row2['stock']; $date=$row2['sell_by_date']; if ($itemquan>=$stock) { // if quantity is bigger than stock in sellby date, e.g. quant=5, stock=1 $itemquan=$itemquan-$stock; //quan=4 $newstock=0;} // stock=0, end loop, insert stock below,go back to beginning of loop, with quan=4, repeat,stock=2, change to quan=2,stock=0 elseif ($stock>$itemquan) { //with quan=2,stock=3 $newstock=$stock-$itemquan; //stock=1 $itemquan=0;} //quan=0, insert below else { echo "error";} } this doesnt work Link to comment https://forums.phpfreaks.com/topic/103263-decrement/#findComment-528887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.