What I want to do is to mark the times and dates in the front-end according to the records of a table, but with the code I have, I can only mark the first row of the table. How can I go through the whole table, marking all the corresponding dates?
I have had a certain success with another while
instead of mysqli_fetch_assoc()
using mysqli_fetch_array()
however it repeats the number of rows in the table, multiplying the times of the front-end . Here is my code:
<div class="row">
<?
for ($i=0; $i < 12; $i++) {
$justDay=date('Y-m-d',strtotime("+$i days"));
$days=formatDt(date('Y-m-d',strtotime("+$i days")));
$dweek= strftime('%A', strtotime("+$i days, today"));
?>
<div class="col-md-1 bord-head-table text-center">
<span class="text-primary"><?= $days;?><br><!--linha exbe semana--></span><br>
<span class="text-white fontweek"><?=utf8_encode($dweek); ?></span>
<hr class="border-lime">
<!-- chama tabela horas-->
<? $sql = "SELECT * from horas";
$qr=mysqli_query($conexao,$sql);
$it=0;
while ($ft=mysqli_fetch_array($qr)) {
$it++;
$sqlAula = "SELECT * from monta_aula";
$qrAula=mysqli_query($conexao,$sqlAula);
$ftAula=mysqli_fetch_assoc($qrAula);
$hrAula=$ftAula['hora_inicio_aula'];
/* compara hora e data da tabela aula com a hora e data do front end e contorna o horário correspondente ao cadastrado no banco, na tabela aula*/
if ($hrAula == $ft['hora'] and $justDay == $ftAula['dia_aula']) {
$hc="border-class";
} else{
$hc="text-green-d";
}
?>
<div class="bord-hours">
<a href="#" class="<?=$hc;?>">
<?=$ft['hora'];?>
</a><br>
</div>
<? }//while ?>
</div>
<!--col md 1 - representa cada coluna, com data, dia da semana e horários (de 08:00:00 às 21:00:00)-->
<? }//for ?>
</div>
<!--row-->
Table to go to:
Hourstable:
FrontEnd: