lundi 18 février 2019

How to simplify if statement into loop

I'm currently doing this if statement here, I wanted to simplify it into a loop. I try putting it into an array for the client_fullname and etc. but turns out only string form can be done. I wanted to simplicity this coding into a loop but i have no idea how to do it.

<tr class="sale" data-id="<?= $sale['id']; ?>">
                    <td><?= $pagination->offset + $key + 1; ?></td>

                    <?php if ($checked_columns['client_fullname']): ?>
                    <td><?= $sale['client_fullname']; ?></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['client_email']): ?>
                    <td> <a href="admin/sales" class="style1"><?php echo $sale['client_email']; ?></a></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['client_phone_number']): ?>
                    <td> <a href="admin/sales" class="style1"><?php echo $sale['client_phone_number']; ?></a></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['total_amount']): ?>
                    <td><?= $sale['total_amount']; ?></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['total_sales_amount']): ?>
                    <td><?= $sale['total_sales_amount']; ?></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['first_date_buy']): ?>
                    <td><?= $sale['first_date_buy']; ?></td>
                    <?php endif; ?>

                    <?php if ($checked_columns['created_at']): ?>
                    <td><?= $sale['created_at']; ?></td>
                    <?php endif ?>

                </tr>

Aucun commentaire:

Enregistrer un commentaire