I did it in a way that I did on my own.
First I looped through all the data in the table and compared the hours.
$select = mysqli_query($db, "SELECT * FROM programas");
while($mos2=mysqli_fetch_assoc($select)){
$str_inicio=strtotime($mos2['hora_inicio']);
$str_fim=strtotime($mos2['hora_fim']);
$str_atual=strtotime($hora_toda);
$diferenca=$str_fim-$str_atual;
if($str_atual > $str_inicio && $str_atual < $str_fim){
$variavel = $mos2['id'];
}
}
With this, it will return what has the id
that I want to submit to ensure.
$select2=mysqli_query($db, "SELECT * FROM programas where id = '".$variavel."'");
if(mysqli_num_rows($select2)){
$mos=mysqli_fetch_assoc($select2);
$radio = $mos['hora_inicio']." - ".$mos['hora_fim'];
echo $mos['img'].",".$mos['nome'].",".$radio.",".str_replace(" ", "_", $mos['nome']);
}
Note: The last echo
is used later in the code in the code so no explanation is needed.