<?
$idga = $_GET['idga'];

//





$sqlturno = "select h_id, concat(date_format(h_horaini,'%k:%i %p'),' - ',date_format(h_horafin,'%k:%i %p')) as hora, h_horaturn as turno, h_horanum as numhora from tb_horario where h_id='$idh'";
$resultturno = mysql_query($sqlturno);
echo "<table>";
while ($row= mysql_fetch_array($resultturno)){
echo "<td>".$row['hora']."</td><td>".$row['turno']."</td><td>".$row['numhora']."</td>";
}

for ($i=1;$i<=count($codprog);$i++){
$sqlconsultaturno="select ut_codprog, hp_tipohora from tb_horaprog where j_id='$iddepa' and s_id='$idserv' and uap_mes='$mm' and uap_anno='$anno' and hp_dia='$i' and h_id='$idh' and a_id='$ida' and ga_id='$idga' and tp_id='$per' and hp_idserva='$idserva'";
$resultcontur = mysql_query($sqlconsultaturno);
$dia= date("w",mktime( 0, 0, 0, $mm, $i, $anno )); 
if(mysql_num_rows($resultcontur)==0){
echo "<td></td>";
}else{
while($rowt= mysql_fetch_array($resultcontur)){
switch ($dia) {
    case 0: echo "<td align='center'>"; if($rowt['hp_tipohora']==1){ echo $rowt['ut_codprog']."e</td>";}else{ echo $rowt['ut_codprog']."</td>";} break;
    case 1: 
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
        echo "<td align='center'><b>"; if($rowt['hp_tipohora']==1){ echo $rowt['ut_codprog']."</b></td>";}else{ echo $rowt['ut_codprog']."</b></td>";} break;
}
}
}}
echo "</tr></table>";




?>