I ran tests with the example and it’s running as you explained.
I tried to comment on the code as much as possible in a simple way.
$limit = 10;
$counter = 1;
$categoria = null;
while( ... )
{
// verifica se mudou a categoria, e inicia o contador se for maior que 1
if( $categoria !== $row['categoria'] and $counter > 1 )
$counter = 1;
if( $counter === 1 )
{
echo $e['categoria'];
}
else
{
echo '<div style="display:none;">' . $e['categoria'] . '</div>';
// reinicia o contador se for maior que o decimo item
if( $counter === $limit ) $counter = 0;
}
// incrementa o contador e grava a categoria atual
$counter++;
$categoria = $e['categoria'];
}
Some situations to illustrate the grouping
• category['A'] 10 records
» 1st Visible and 9 Hidden
• category['A'] 15 records
» 1º Visible and 9 Hidden + 1 Visible and 4 Hidden
• category['A'] 10 records | category['B'] 5 records
» 1º Visible and 9 Hidden(CAT-A) + 1 Visible and 4 Hidden(CAT-B)
• category['A'] 5 records | category['B'] 10 records
» 1º Visible and 4 Hidden(CAT-A) + 1 Visible and 10 Hidden(CAT-B)
I don’t understand the problem, you can post part of the code?
– Papa Charlie
@Papacharlie I have a field called "category" and in it has the category of record. I have for example 10 records all with the same category. I wanted to pick up and list on the screen 1 record and the other 9 list too, only that leave with the style="display:Hidden"
– Alisson Acioli
It excludes my previous answer because it was incomplete, I did not change it so that the comments were not meaningless... I posted a new answer based on what I understood of gave problem.
– Papa Charlie