CodeIgniter Forums
Display table row following condition - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Display table row following condition (/showthread.php?tid=81325)



Display table row following condition - plopli - 02-16-2022

I have a table in our admin panel. The table display the coupon and the deal, but for a better reading we would like to have a split table. 1 for coupons and 1 for deals.
I can't figure out how to display only the data according to the status if deal or coupons.
Here below is my loop to get all the data, and create the table.

PHP Code:
<tbody>
    <?php 
    $this
->load->helper('text');
    $count 0;
    foreach ($result as $key => $value) {
        $count++;?>  
        <tr>
        <td><?php echo $count;?></td>
        <td><?php echo  wordwrap($value->deal_title,25,"<br>\n");?></td>
        
        <td> <?php 
                
if($value->deal_type == 0){
                    echo 'Deal';
                }else{
                    echo 'Coupon';
                }
            ?>  </td>
        
        <td> <?php 
                $ext 
explode(' '$value->created_at);
                echo $ext[0];
            ?>
            </td>
        <td>
            <?php 
                $user_details 
get_likes($value->id);
                echo @$user_details[0]->likes
            ?>
        </td>
            <td>
            <?php 
                
if($value->deal_status == 1){
                    echo 'Not published';
                }else{
                    echo 'Published';
                }
            ?>
        </td>                                
        
        </tr>
    <?php }?>
</tbody> 



RE: Display table row following condition - demyr - 02-16-2022

Hi. Why don't you take your if control out of your <tr> ?
Or you can fetch 2 different datas from your controller and you can display one of them according to your if statement. ??