Andy11548 Posted July 9, 2011 Share Posted July 9, 2011 Is it possiable for me to put a IF statement into a while loop? I want it so it's like: do { if($admin = yes) { } else { } } while(code here); but, I get errors when I do that. Thanks, Andy. Quote Link to comment https://forums.phpfreaks.com/topic/241507-whileif/ Share on other sites More sharing options...
QuickOldCar Posted July 9, 2011 Share Posted July 9, 2011 something like this? if($admin != "yes"){ echo "redirect or show message"; } else { while(code here){ echo "code"; } } Quote Link to comment https://forums.phpfreaks.com/topic/241507-whileif/#findComment-1240567 Share on other sites More sharing options...
davidmyers Posted July 9, 2011 Share Posted July 9, 2011 What kind of errors are you getting? Because it is perfectly logical to put if else statements within loops. Quote Link to comment https://forums.phpfreaks.com/topic/241507-whileif/#findComment-1240569 Share on other sites More sharing options...
Andy11548 Posted July 9, 2011 Author Share Posted July 9, 2011 Nevermind, it wasn't working before, but I just re-typed the code and it worked. The error I was getting was onabout "T_IF" or something. Nevermind, Thanks anyways, Andy. Quote Link to comment https://forums.phpfreaks.com/topic/241507-whileif/#findComment-1240570 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.