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 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 " "; } ?> 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 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 Link to comment https://forums.phpfreaks.com/topic/52191-solved-if-statement/#findComment-257420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.