Select prioritized and sorted by field

0

Well,IhaveaschedulescheduleandIneedtodisplaythespeakerthatisliveatthemoment,I'mpickingupviaphpthedatesandplayingintheselect,butseveraltimesitleavesormessesuporitdoesnotworkout,I'lltrytosummarizewhatIhaveinordertofacilitate.Rememberthatyoucanhavethesametimeondifferentdays,soORDERBYFIELDwillgivepriorityto$today.

<?php$diasemana=array('Domingo','Segunda','Terca','Quarta','Quinta','Sexta','Sabado');$data=date('Y-m-d');$diasemana_numero=date('w',strtotime($data));$hoje=$diasemana[$diasemana_numero];$hora=date("H");
 $minuto = date("i");
 $horaatual = $hora."h".$minuto;
 try {
    $sql = "SELECT * FROM programacao WHERE horafinal >= '$horaatual' ORDER BY FIELD(dias,'$hoje','De Segunda a Sexta','De Segunda a Sabado'), horafinal ASC LIMIT 1";

I do not know if this in logic or in programming even the error, if in case someone has some better idea I also accept suggestions.

    
asked by anonymous 04.10.2016 / 17:05

0 answers