Michdd Posted December 6, 2008 Share Posted December 6, 2008 I have a MySql loop that has an if statement in it, how do I make it so that it will exit the loop when the if statement is true? Quote Link to comment https://forums.phpfreaks.com/topic/135821-loop/ Share on other sites More sharing options...
laPistola Posted December 6, 2008 Share Posted December 6, 2008 show us the code please Quote Link to comment https://forums.phpfreaks.com/topic/135821-loop/#findComment-707907 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 If it is a while loop use break; Quote Link to comment https://forums.phpfreaks.com/topic/135821-loop/#findComment-707908 Share on other sites More sharing options...
RichardRotterdam Posted December 6, 2008 Share Posted December 6, 2008 I have a MySql loop that has an if statement in it, how do I make it so that it will exit the loop when the if statement is true? you can use a break in any loop foreach($somearray as $value){ if($something){ break; } } Quote Link to comment https://forums.phpfreaks.com/topic/135821-loop/#findComment-707912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.