Welcome Guest, Not a member yet? Register   Sign In
Display table row following condition
#1

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> 
Reply
#2

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. ??
Reply




Theme © iAndrew 2016 - Forum software by © MyBB