1
I have a system in which I register the number of people in a given establishment that goes from 1 to 200 and each establishment holds up to 3 people. How I would make it so that when I bring this amount from mysql, it is divided into blocks. For example.:
As I’m currently bringing
<?php
....
$c = 1;
while($jm = mysqli_fetch_object($sqlMostrar)){
$mostrar .= "Estabelecimento " . $c . "<br>";
$mostrar .= $jm->Nome. " " .$jm->Idade;
$c++;
}
This way it brings rushed and not in blocks. I would like to bring this result as follows. Let’s assume that the client registered 09 people:
**Estabelecimento 1**
Fernando Pessoa 32 anos
Ruth Cardoso 56 anos
Santos Dumont 60 anos
**Estabelecimento 2**
Carlos Drummond de Andrade 70 anos
Mario Lago 72 anos
Manuel Bandeira 60 anos
**Estabelecimento 3**
Olavo Bilac 22 anos
Cecília Meireles 25 anos
Gonçalves Dias 55 anos
Hi Wallace, I used your code, but it gives the error Call to Undefined Function mysqli_fetch_all(). The php version is 5.5.29. Is there any incompatibility?
– user24136
Hi Wallace. Unfortunately this last example of yours didn’t work either. It doesn’t show the result after if parole().
– user24136
For the first question: Yes, the error occurs because you are using a version less than 5.3 of PHP.
– Wallace Maxters
For the second question: I used your sample code. Make sure you started the variable
$mostrar
before the loop.– Wallace Maxters
There is an error in the code: The
$d
has to be0
– Wallace Maxters
I put $contar = $jmListar->Qtdpax; for($cc = 0; $cc < $count; $cc++) and it worked correctly.
– user24136
Just one more question to close. Let’s assume that the blocks are divided into 2 and in the bank bring 5, automatically the last field will contain only one. How would I make even with the difference, it closes with 02 blocks?
– user24136