How do I create an if statement which uses both greater than and less than I want to display 'Excellent Cheat' if the rating is between 0 and 1.5 so >0 and <1.5 'Good Cheat' if the rating is between 1.5 and 2.5 so >=1.5 and <2.5 'Ok Cheat' if the rating is between 2.5 and 3.5 so >=2.5 and <3.5 I dont know how to do this in php though i tried this: if ($overall<1.5) ($overall>0); {$CheatRating = "Excellent Cheat";} if ($overall<2.5) ($overall>1.5); {$CheatRating = "Good Cheat";} if ($overall<3.5) ($overall>2.5); {$CheatRating = "Ok Cheat";} if ($overall<4.5) ($overall>3.5); {$CheatRating = "Poor Cheat";} PHP: but it didnt seem to work as it found 'poor cheat' everytime. any help is very much appreciated. Thanks
if ($overall<1.5 && $overall>0); {$CheatRating = "Excellent Cheat";} if ($overall<2.5 && $overall>1.5); {$CheatRating = "Good Cheat";} if ($overall<3.5 && $overall>2.5); {$CheatRating = "Ok Cheat";} if ($overall<4.5 && $overall>3.5); {$CheatRating = "Poor Cheat";} I think thats what your trying to do.
Looks about right thanks, I understand the code but just didnt know that & was needed. Little things like that can save me hours cheers
Hi there, This should work too: $overall = 1.7; switch ($overall) { case ((($overall > 0) and ($overall < 1.5))?$overall:false): $cheatRating = "Excelent cheat"; break; case ((($overall >= 1.5) and ($overall < 2.5))?$overall:false): $cheatRating = "Good cheat"; break; case ((($overall >= 2.5) and ($overall < 3.5))?$overall:false): $cheatRating = "OK cheat"; break; case ((($overall >= 3.5))?$overall:false): $cheatRating = "Poor cheat"; break; default: $cheatRating = "Poor cheat"; break; } PHP: Result: $cheatRating = "Good cheat".
There are times when it's easier on the brain just to use if rather than a switch/case/break set. if ( $overall < 1.5 && $overall > 0 ) $CheatRating = 'Excellent Cheat'; if ( $overall < 2.5 && $overall >= 1.5 ) $CheatRating = 'Good Cheat'; if ( $overall < 3.5 && $overall >= 2.5 ) $CheatRating = 'Ok Cheat'; if ( $overall < 4.5 && $overall >= 3.5 ) $CheatRating = 'Poor Cheat'; if ( $overall >= 4.5 ) $CheatRating = '...'; PHP: