I did it in a way that I did it alone.
First I looped through all the data in the table and proceeded to compare 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, he will return what he has id
which I wish to present.
$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 personally later in the code so no explanation is needed.
which bank? you want to select in query or compare in code
php
?– Ricardo Pontual
You want to know if the current time is between the two times that are in the bank?
– Geraldão de Rívia
Yes, it is possible?
– I_like_trains
is yes, see if the answer I posted meets you
– Geraldão de Rívia