<?php
$iddepa= $_GET['idj'];
$idserv= $_GET['ids'];
$idga=$_GET['idga'];
$ida=$_GET['ida'];

include("bd/sql_variables.php");
$con= mysqli_connect("$sql_host", "$sql_usuario", "$sql_pass") or die(header ("No Disponible Servidor de Base de Datos"));
mysqli_select_db($con,"$sql_db");

$sqlh = "select a.h_id as idh, concat(date_format(b.h_horaini,'%k:%i %p'), ' - ',date_format(b.h_horafin,'%k:%i %p')) as hora, h_horaturn as turno, h_horanum as numhora from areahora a inner join tb_horario b on a.h_id=b.h_id where a.s_id='$idserv' and a.j_id='$iddepa' and a.ga_id='$idga' and a.a_id='$ida' and a.ah_estado=1";

$resulth = mysqli_query($con,$sqlh);

if ($resulth == false){
echo 'PROVOCO UN ERROR EN LA CONSULTA';
}else{
echo "Seleccione Horario: <select name='hora' id='hora".$idga.$ida."'>";

while ($rowh= mysqli_fetch_array($resulth)){
echo "<option value='".$rowh['idh']."'>".$rowh['hora']."</option>";
}
echo "</select>";
}

?>