Conditional style for specific data in PHP - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Conditional style for specific data in PHP (/showthread.php?tid=80370) |
Conditional style for specific data in PHP - JJM50 - 10-24-2021 Currently I have a table displaying all of the agents and a count of their leads status shown in the same row. Now these agents can be Active or Inactive, but both are shown in my table. This active/inactive status is shown in my users table under the status column as either Y or N. Now this is the code I'm using to get my data: Model Class: Code: function get_agentsreport(){ View Class: Code: <?php Now I'm trying to differentiate the active and inactive users by a change in the style and as shown here I've tried if($grplead['status'] == "N"){$inactive_status == true;} but in my table it always goes to the else statement and doesn't compute the first if statement. I've also tried if($grplead['status'] == "Y"){$inactive_status == true;} but it gives the same output. I've tried logging this status by print_r($grplead['status']); which gave the correct result like YYYYNY. So it is giving the correct status for each person, but for some reason it does not work in my if condition RE: Conditional style for specific data in PHP - includebeer - 10-25-2021 The bug is here : PHP Code: if($grplead['status'] == "N"){ $inactive_status is never initialized. There should only be one equal sign, and it should be set to false if status is not equal to N : PHP Code: if($grplead['status'] == "N") { …and could be simplified like this : PHP Code: $inactive_status = ($grplead['status'] == "N"); |