I have one table named tb_dias that as 11 days inside. Each day as a id that identifies it.
I have other table called tb_disponibilidade, this table contains
id_nadador id_dia
Im getting all the 'dia' from tb_dias and making them as headers in my html table. My goal is to put all the id_nadador that are in each day, something similiar to this:
But what i am getting is this. My code isn't putting only the id_nadador that corresponds to each day, he is putting all the ids in the first day
My tables:
<table class='tutorial-table'>
<thead>
<tr>
<?php
$sqlSelect = "SELECT * FROM tb_dias";
$result = $db->select($sqlSelect);
if (! empty($result)) {
foreach ($result as $row) {
echo "<th>".$row['dia']."</th>";
}}
?>
</tr>
</thead>
<?php
$sqlSelect = "SELECT tb_disponibilidade.id_nadador,tb_dias.id_dia,tb_nadadores.nome
FROM ((tb_disponibilidade
INNER JOIN tb_dias ON tb_disponibilidade.id_dia = tb_dias.id_dia)
INNER JOIN tb_nadadores ON tb_disponibilidade.id_nadador = tb_nadadores.id_nadador);";
$resultado = $db->select($sqlSelect);
foreach ($resultado as $res) {
var_dump($res);
// ($row = mysqli_fetch_array($result))
?>
<tbody>
<tr><?php
echo '<td>' .$res['id_nadador']. '</td>';
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
?>


