Crustyfur Posted May 20, 2007 Share Posted May 20, 2007 Hi, I am a relative newbie to php so please be kind I am trying to use the if statement to make a display based on comparing two values, pretty simple. Here's what I have: if($ffor > $fagg) echo " (L)"; elseif($ffor >= $fagg) echo " (D)"; elseif($ffor < $fagg) echo " (W)"; elseif(!empty($row[8])) echo " "; What I want it to do is not return any results when $ffar and $fagg are empty/null results. I am struggling as it keeps returning null values as a (D). Any help would be appreciated. Chris Quote Link to comment https://forums.phpfreaks.com/topic/52191-solved-if-statement/ Share on other sites More sharing options...
chigley Posted May 20, 2007 Share Posted May 20, 2007 <?php if(!isset($ffor) || !isset($fagg)) { // If either is empty, just output a space. Then run the rest of your if's. echo " "; } elseif($ffor > $fagg) { echo " (L)"; } elseif($ffor >= $fagg) { echo " (D)"; } elseif($ffor < $fagg) { echo " (W)"; } elseif(!empty($row[8])) { echo " "; } else { echo " "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52191-solved-if-statement/#findComment-257390 Share on other sites More sharing options...
Crustyfur Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks chigley, I was sort of the right lines... :-\ heh Cheers Quote Link to comment https://forums.phpfreaks.com/topic/52191-solved-if-statement/#findComment-257419 Share on other sites More sharing options...
chigley Posted May 20, 2007 Share Posted May 20, 2007 You're welcome Quote Link to comment https://forums.phpfreaks.com/topic/52191-solved-if-statement/#findComment-257420 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.