How to ignore an empty row in a table

Asked

Viewed 53 times

1

I am making a table and when a value is empty I would like you to ignore the value and be filled with the next row with value.

With the code below, nothing appears, neither value nor worthless.

<table class="table table-striped" id="tblGrid">
<thead>
<tr>
<th align="left">Observações</th>
</tr>
</thead>
<tbody>
    <?php while ($row_itens_vazio = $resultado_itens_vazio->fetch_array()) {?>
      <tr>
      <?php if($row_itens_vazio["obs_tab_itens_cot"]>0){?>
        <td align="left" class="td1">
           <?php echo $row_itens_vazio["obs_tab_itens_cot"];?>
        </td>
           <?php } ?> 
      </tr>
    <?php } ?> 
</tbody>
</table>
  • 1

    The variable $resultado_itens_vazio is receiving what data?

  • Put to query for us.

1 answer

1


You can solve this by using the continue and the empty php.

Example

<table class="table table-striped" id="tblGrid">
<thead>
<tr>
<th align="left">Observações</th>
</tr>
</thead>
<tbody>
    <?php while ($row_itens_vazio = $resultado_itens_vazio->fetch_array()) {
             //verifica se um valor é vazio.
             if(empty($row_itens_vazio['obs_tab_itens_cot'])) {
                 continue; //volta para cima no próximo registro
             }
      ?>
      <tr>
      <?php if($row_itens_vazio["obs_tab_itens_cot"]>0){?>
        <td align="left" class="td1">
           <?php echo $row_itens_vazio["obs_tab_itens_cot"];?>
        </td>
           <?php } ?> 
      </tr>
    <?php } ?> 
</tbody>
</table>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.