Limit the number of columns in a dynamically populated table

Asked

Viewed 26 times

-2

I have a table that is filled dynamically, after two queries in the database. However it inserts the columns side by side, getting very wide the table, not fitting on the screen. I wonder if I can get her after reaching 10 columns, to continue in another row, and so on until it’s over. Follows the code:

 <table border="1" width="80%" cellspacing="10" cellpadding="5">
    <tr>
        <?php
        $matriculas = 0;
        $pagamentos = 0;
        for ($a = '0'; $a < $qtdRow; $a++) { ?>
            <?php if (($matriculaGrid[$a]['idcurso']) == ($matriculaGrid[$a]['matidcurso'])) { ?>
                <?php $matriculas += 1; ?>
            <?php } ?>
            <?php if (($matriculaGrid[$a]['idcurso']) == ($matriculaGrid[$a]['pagidcurso']) && ((($matriculaGrid[$a]['pago']) == 2) OR (($matriculaGrid[$a]['pago']) == 3))) { ?>
                <?php $pagamentos += 1; ?>
            <?php } ?>
            <?php if (($matriculaGrid[$a]['matidcurso'] != @$matriculaGrid[$a + 1]['matidcurso'])) { ?>
                <td>
                    <?php echo $matriculaGrid[$a]['nomecidade']; ?><br>
                    <?php echo implode('/', array_reverse(explode('-', $matriculaGrid[$a]['datainicio']))); ?>
                    á <?php echo implode('/', array_reverse(explode('-', $matriculaGrid[$a]['datafim']))); ?><br>
                    <?php echo "MATRICULAS        " . $matriculas; //$matriculas = 0; ?>
                    <?php echo "PAGAMENTOS        " . $pagamentos; //$matriculas = 0; ?>
                </td>
                <?php //echo "PAGAMENTOS        " . $pagamentos; //$matriculas = 0; ?></td>
                <?php $matriculas = 0;
                $pagamentos = 0;
            } ?>
        <?php } ?>
    </tr>
</table>
No answers

Browser other questions tagged

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