I have a problem when showing records in my table the problem is the following: in the header of the table I show the hours that would be eight in total and below the header the results of the numbers that have come out are shown according to the time and day, but the problem arises that the first week of Thursday recorded some data and now the second week of Thursday you must register the other data of that same day but I am still showing in the same row when it should be shown below because it is supposed to be the same day but different results attached an image and to show how it should look and my error currently presented.
source code
<div id="test5" class="center-align light">
<?php
$consulta = $DB_con->query("SELECT * FROM hora_sorteo");
for ($set = array (); $row = $consulta->fetch(PDO::FETCH_ASSOC); $set[] = $row);
?>
<table class='striped responsive-table centered'>
<thead>
<tr>
<?php for($i=0;$i<count($set);$i++){
echo "<th>" . $set[$i]['hora_sorteo'] . "</th>"; //muestra las horas de jugada
}?>
</tr>
</thead>
<?php
$consulta2 = $DB_con->query("SELECT
animalitos.id,
animalitos.numero,
resultado.id,
resultado.fk_animalitos,
resultado.fk_hora_sorteo,
resultado.fk_dias,
resultado.fecha,
hora_sorteo.id,
hora_sorteo.hora_sorteo,
dias.id,
dias.dias
FROM animalitos
INNER JOIN resultado ON animalitos.id=resultado.fk_animalitos
INNER JOIN hora_sorteo ON resultado.fk_hora_sorteo=hora_sorteo.id
INNER JOIN dias ON resultado.fk_dias=dias.id
WHERE resultado.fk_dias='5' ORDER BY resultado.id ");
for ($set2 = array (); $row = $consulta2->fetch(PDO::FETCH_ASSOC); $set2[] = $row);
?>
<tr>
<?php for($b=0;$b<count($set2);$b++){
echo "<td>" . $set2[$b]['numero'] . "</td>"; //muestra los
resultados de los numeros
}?>
</tr>
</table>
</div>