chadrt Posted May 20, 2017 Share Posted May 20, 2017 Ok here goes this little experiment... if (($coumadinEntry->inr >= 2) && ($coumadinEntry->inr <= 3)) { $coumadinINR = $coumadinEntry->inr." It's Good"; }else{ $coumadinINR = $coumadinEntry->inr." Adjustment Needed"; } this is located in a "foreach" building a table and although "It's Good" works reliably it now fills every box in that column with "Adjustment Needed" unless that column is between 2 and 3. What I am wanting to happen is: If between 2 and 3 it shows the level INR and "It's Good" If below 2 it will show something else (likely "actual reading and an icon of some sort on each side of the number) If above 3 it show something else (likely "actual reading and an icon of some sort on each side of the number) if empty or NULL then it will set $coumadinINR=""; so nothing is displayed Link to comment Share on other sites More sharing options...
requinix Posted May 20, 2017 Share Posted May 20, 2017 Okay... so... do that? You already seem to understand how comparisons work so write a couple more of them. Link to comment Share on other sites More sharing options...
chadrt Posted May 20, 2017 Author Share Posted May 20, 2017 if (($coumadinEntry->inr >= 2) && ($coumadinEntry->inr <= 3)) { $coumadinINR = $coumadinEntry->inr." It's Good"; }elseif($coumadinEntry->inr < 2){ $coumadinINR = $coumadinEntry->inr." It's Low"; }elseif($coumadinEntry->inr > 3){ $coumadinINR = $coumadinEntry->inr." It's High"; }else{ $coumadinINR = ""; } Ok so there is my hundredth attempt at this. I know why its failing but I don't how to correct for it. At this point because NULL is less than 2 it assumes that this is true and displays the "It's Low" with no value. I thought this was the answer but I am missing something. I if (($coumadinEntry->inr >= 2) && ($coumadinEntry->inr <= 3)) { $coumadinINR = $coumadinEntry->inr." It's Good"; }elseif($coumadinEntry->inr < 2) && ($coumadinEntry->inr != ''){ $coumadinINR = $coumadinEntry->inr." It's Low"; }elseif($coumadinEntry->inr > 3){ $coumadinINR = $coumadinEntry->inr." It's High"; }else{ $coumadinINR = ""; } I think I am on the right track but its kicking me still... if (($coumadinEntry->inr >= 2) && ($coumadinEntry->inr <= 3)) { $coumadinINR = $coumadinEntry->inr." It's Good"; }elseif(is_null($coumadinEntry->inr)){ coumadinINR = ""; }elseif($coumadinEntry->inr < 2){ $coumadinINR = $coumadinEntry->inr." It's Low"; }elseif($coumadinEntry->inr > 3){ $coumadinINR = $coumadinEntry->inr." It's High"; }else{}; Link to comment Share on other sites More sharing options...
chadrt Posted May 20, 2017 Author Share Posted May 20, 2017 oh my brain hurts now, us amateurs should be banned from any kind of code if (($coumadinEntry->inr >= 2) && ($coumadinEntry->inr <= 3)) { $coumadinINR = $coumadinEntry->inr." It's Good"; } elseif(is_null($coumadinEntry->inr)){ $coumadinINR = ""; } elseif($coumadinEntry->inr < 2){ $coumadinINR = $coumadinEntry->inr." It's Low"; } elseif($coumadinEntry->inr > 3){ $coumadinINR = $coumadinEntry->inr." It's High"; }else{} But alas its done and it works... Link to comment Share on other sites More sharing options...
kicken Posted May 20, 2017 Share Posted May 20, 2017 if ($coumadinEntry->inr === null){ $coumadinINR = ""; } else if ($coumadinEntry->inr < 2){ $coumadinINR = $coumadinEntry->inr." It's Low"; } else if ($coumadinEntry->inr > 3){ $coumadinINR = $coumadinEntry->inr." It's High"; } else { $coumadinINR = $coumadinEntry->inr." It's Good"; }Start with your null condition so it doesn't get mixed up with the < 2 condition. Then check your less than or higher than conditions. If those all fail then it must be 2 or 3. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.