Jump to content

[SOLVED] Interesting While Loop Keeps Timing Out.


DamienRoche

Recommended Posts

So I just got into while loops and have constructed this beast:

 


$e1fname = "text";             ///////////$e2fname etc. etc.
$e1sname = "";                                  ""         ""
$e1passport = "text";                          ""         ""

$loop = "1";
$limit = "3";
$Y = "0";
$N = "0";
while ($loop <= $limit){

$fb = "e".$loop."fname";
$sb = "e".$loop."sname";
$pb = "e".$loop."passport";
$cb = "e".$loop."check";

if($cb!=""){
if($fb!="" && $sb!="" && $pb!=""){
$Y = $Y + 1;}else{$N = $N + 1;}
}

}

if($N > 0) {echo "The while loop returned an N";}

 

The problem here is that the loop is timing out when it should only run it 3 times? is it because of the nested if statements? What is best practice here? or have I missed something, yet again?

 

Thanks.

 

OMG I cannot believe I did not increment the loop. I can only code for so long before ALL of my problem solving skills are washed away with the last bit of coffee in my mug.

 

Thank you again!!

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.