<? while ($row=mysql_fetch_array($result)){ if ($dia2!=$row[dia]){ echo $row[dia];} echo "$row[hora] - $row[programa]"; $dia2=$row[dia]; } ?>