Jump to content

decrement??


anser316

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.