Show fields if different from 0 (zero)

0

How to display the fields of each record in the table, if the field N is nonzero?

    </td> 
    </tr>

    <tr>
    <td><?php echo $customer['produto2']; ?></td>
    <td><?php echo $customer['serial2']; ?></td> 
    </tr>

    <tr>
    <td><?php echo $customer['produto3']; ?></td>
    <td><?php echo $customer['serial3']; ?></td> 
    </tr>

    <tr>
    <td><?php echo $customer['produto4']; ?></td>
    <td><?php echo $customer['serial4']; ?></td> 
    </tr>

    <tr>
    <td><?php echo $customer['produto5']; ?></td>
    <td><?php echo $customer['serial5']; ?></td> 
    <tr>                
</tr>
    
asked by anonymous 20.02.2017 / 22:01

1 answer

1

You can check that produtoN exists in the array with isset() and also check if it is different from 0:

<?php if(isset($customer['produto4']) && $customer['produto4'] != 0) { ?>
    <tr>
        <td><?php echo $customer['produto4']; ?></td>
        <td><?php echo $customer['serial4']; ?></td> 
    </tr>
<?php } ?>
    
21.02.2017 / 01:15