Snooble Posted March 4, 2007 Share Posted March 4, 2007 <?php if($list['point'] == "0"){ echo " Rank : Newbie"; } elseif($list['point']. < "5" && != "0"){ echo " Rank : Beginner"; } elseif($list['point']. < "10" && => "5"){ echo " Rank : Rookie"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/41109-if-statement-small-code-should-be-easy/ Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 <?php if($list['point'] == 0){ echo " Rank : Newbie"; } elseif($list['point'] < 5){ echo " Rank : Beginner"; } elseif($list['point'] < 10){ echo " Rank : Rookie"; } ?> This would work. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/41109-if-statement-small-code-should-be-easy/#findComment-199119 Share on other sites More sharing options...
Snooble Posted March 4, 2007 Author Share Posted March 4, 2007 Works beautifully. Thought it'd print em all. But obviously hits the one that works and stops. Thanks Snooble Quote Link to comment https://forums.phpfreaks.com/topic/41109-if-statement-small-code-should-be-easy/#findComment-199124 Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 That's the whole idea of if/elseif/else. Once it enters one of the blocks, it doesn't enter the others. If something is true- do action1. elseif something is true -> if the first condition was false and this condition is true- do action2. elseif something is true -> if the last elseif was false and this condition is true -> if the first condition was false, the previous condition was false is true and this condition is true -> do action3. else -> if everything was false- do action4. Get the idea? Orio. Quote Link to comment https://forums.phpfreaks.com/topic/41109-if-statement-small-code-should-be-easy/#findComment-199126 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.