Lo que podrias hacer es hacer uso de
pg_num_rows() para verficar si tienes resultados
Código PHP:
<?
.
.
.
$query = "SELECT cedula, fecha, SUM(horas) AS horastotales, contrato FROM maestro WHERE contrato = '$contrato' AND Fecha BETWEEN '$fecha_del' AND '$fecha_al' GROUP BY cedula, fecha, contrato";
$result=pg_Exec($conn,$query);
$num = pg_num_rows($result);
if($num >0)
{
.
.
.
?>
Saludillos.