I have a table in the bank with a team register, where each line corresponds to an employee and his respective team. For example,
employee_id, employee
1, Mario
1, Sérgio
2, John
2, Joseph
I want to bring the data on the screen into a table so that each row corresponds to each team, and the column employees is a concatenation of the names. This is:
team_id, employees
1, Mario, Sergio
2, John, Joseph
What I have so far:
<table id="myDatatable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nome Equipe</th>
<th>Funcionários</th>
<th>Ações</th>
</tr>
</thead>
<?php
$id_agencia = $_SESSION['id_agencia'];
$pdo = Conexao::getInstance();
$dados = $pdo->prepare("SELECT DISTINCT(nome_equipe),id_equipe,id_eletricista FROM quadro WHERE id_agencia=:id AND status=1 GROUP BY nome_equipe");
$dados->bindParam(':id',$id_agencia, PDO::PARAM_INT);
$dados->execute();
if($dados->rowCount()>=1){
echo '<tbody>';
while($table = $dados->fetch(PDO::FETCH_OBJ)){
echo '<tr>';
$id_equipe=$table->id_equipe;
echo'<td>'.$table->nome_equipe.'</td>';
echo'<td>'.$table->id_eletricista.'</td>';
echo '<td><a class="btn btn-success" href="editando_equipe.php?id='.$id_equipe.'"><i class="fa fa-edit"></i> Editar</a>
<a class="btn btn-warning" href="Quadro/desativar_equipe.php?id='.$id_equipe.'&Acesso=0" title="Desativar equipe"><i class="fa fa-minus-circle"></i></a>
</td>';
}
}
echo '</tr>';
echo '</tbody>';
?>
</table>
</div>
</div>
</div>
</div><!-- div da row anterior class="col-md-6 col-xs-12"-->
</div>
Who can give me tips on how to achieve this goal, thank you very much! Any help is welcome!