0
I’m wondering how to build a dynamic table with PHP.
I am mounting an HTML table in which will be displayed some data registered in a database, already created the SELECT
which brings the database information, but I’m doubtful how to build the loop to display the information as the table will have 4 columns.
I tried to make a noose FOR
however he displayed the table as follows.
Item 1 | Item 1 | Item 1 | Item 1
Item 2 | Item 2 | Item 2 | Item 2
Item 3 | Item 3 | Item 3 | Item 3
When should I display
Item 1 | Item 2 | Item 3 | Item 4
Item 5 | Item 6 | Item 7 | Item 8
Item 9 | Item 10 | Item 11 | Item 12
Loop structure
<?php while ( $linha = mysqli_fetch_assoc($executaSelect) ) { ?>
<tr>
<?php for ($i = 1 ; $i <= 4 ; $i++) { ?>
<td><?php echo $linha["nome"]; ?></td>
<?php } ?>
</tr>
<?php } ?>
See if this helps you http://codigofonte.l.com.br/codigos/gerar-uma-lista-em-html-a-partir-de-consulta-mysql-comphp
– MeuChapeu