please look at this code,

for ($count=$num1; $count<=$num2; $count++){
		for ($count1=1; $count1<=2; $count++){
		echo $count1;
		}
	  }

why this is never ending loop ?
when i run this code my browser hanged, why it is happening ??

Recommended Answers

All 4 Replies

what are values of, num1 and num2.
Your second loop will never execute. eveyting depends on num1 and num2

num1 and num2 are input through the form and num1 is always less than num2.

what are values of, num1 and num2.
Your second loop will never execute. eveyting depends on num1 and num2

your $count1 value is always less than 2 because its not incremented anywhere...
I think in your inner for loop you should increment $count1++ instead of $count++

hey thanks for spotting my mistake !!
thankyou !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.