Questo è il codice che ho scritto con le modifiche da te indicate :
Quello che mi restituisce è la divisone fra le categorie ma ognuna delle categorie ha solo un elemento ( un solo DIV Rosso) , dove sbaglio?$thread_qry1 = "SELECT * FROM `xt_teams` AS u, `xt_player` AS m WHERE (u.name_team = m.team_name AND m.accepts = 1) ORDER BY u.console_team";
$row1 = XenForo_Application::get('db')->fetchAll($thread_qry1);
$teamCurrent = '';
$i = 1;
$count = 1;
$size = count($row1);
$category = '';
foreach ( $row1 AS $rows1 ) {
if($category != $rows1['console_team']){
if ($teamCurrent != $rows1['name_team'])
{
$ii = $i++;
if($teamCurrent != '') echo ('</div>');
echo ('<h2 class="trigger01">
<div style="height:100px; width:100%; background-color:red"></div>
</h2>
<div class="containerTeam">
<div style="height:50px; width:100%; background-color:green"></div>
');
$teamCurrent = $rows1['name_team'];
}
echo ('
<div style="height:50px; width:100%; background-color:yellow"></div>
');
if($count == $size)
echo ('</div>');
$count ++;
}
$category = $rows1['console_team'];
}