i have a number of minutes as ceiling and tasks that demand time in minutes, im doing a while loop to sum the time required by the tasks until reach the ceiling, but im having a problem with one step in the loop, the first number is the loop, the second the task required time, the third is my ceiling. I must reset the the task_required_time variable before or once it reach the ceiling. Using
if ($task_required_time > $ceiling) {task_required_time = 0}
it reset after its over the ceiling:
1 - 120 - 2400
2 - 304 - 2400
3 - 424 - 2400
4 - 2092 - 2400
5 - 2212 - 2400
6 - 3580 - 2400 <---- here is when it reset as expected but should be in the step before.
7 - 120 - 2400
8 - 330 - 2400
9 - 450 - 2400
10 - 570 - 2400
I will appreciate some light on it.
You need to make the compare at the begining of the code. this may help:
while ($rows = mysql_fetch_array($duedates)) {
if ($tiempo_para_mix + (($rows['tiempo_reproduccion'])*2)+($tiempo_tqc_final*60) > $tiempo_efectivo) {
$tiempo_para_mix = 0;
};
$tiempo_para_mix += (($rows['tiempo_reproduccion'])*2)+($tiempo_tqc_final*60);
echo $x . " - " . $tiempo_para_mix . " - " . $tiempo_efectivo . "</br>";
$x++;
}