Two different conditions apply to the same value [closed]

-6
<td>
   <? if($online['status']==1){?>
    <span class="badge badge-primary"><?php echo lang('texto um'); ?></span>
   <?}else{?>

   <? }?>

   <?if($online['status']==2){?>
     <span class="badge badge-danger"><?php echo lang('texto dois'); ?></span>
   <? }else{?>

   <? }?>
   ...
</td>

In the table you are printing the two, but it was to print according to the status in the table.

What's wrong?

    
asked by anonymous 30.10.2018 / 20:02

1 answer

-1

Try to do so. Whenever there is a new condition in the "if" use the "elseif":

<td>
    <?php
       if($online['status'] === 1){
    ?>
      <span class="badge badge-primary"><?php echo lang('texto um'); ?></span>
    <?php
      }elseif($online['status'] === 2){
    ?>
      <span class="badge badge-danger"><?php echo lang('texto dois'); ?></span>
    <?php
      }else{
    ?>
      etc etc etc etc continua
    <?php
     }
    ?>
</td>
    
30.10.2018 / 20:20