dzhax Posted August 30, 2009 Report Share Posted August 30, 2009 (edited) I am opening a while and inside the while i have an if statement. If that statement proves true I want to exit the while. Is this possible and how? Couldn't find it on the main w3schools website. $sbanned = mysql_query("SELECT * FROM shoutbans"); while ($sban = mysql_fetch_row($sbanned)){ if ($sban['user'] == $_SESSION['user']) $usrBanned = 'yes'; } if ($ustBanned == 'yes'){ "Show information" } else { echo 'This section is off limits, you are banned from using it.'; } Or if you know of a better way to check if the session user is in the shoutbans table.Basically i made a shout box but I do not want it to show if the logged in user is banned from it. Edited August 30, 2009 by dzhax Link to comment Share on other sites More sharing options...
boen_robot Posted August 30, 2009 Report Share Posted August 30, 2009 First stop, enclose your condition's body with "{}". And second, you can use the break statement. if ($sban['user'] == $_SESSION['user']) { $usrBanned = 'yes'; break;} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now