Hola, estuve investigando un poco, hice lo siguiente...
Código PHP:
Ver original<html>
<head>
<style type="text/css">
td
{
width:10%;
height:20px;
}
</style>
</head>
<body>
<?php
include("conexion.php");
$con=conectar();
$fecha_actual=date('Y-m-d'); $salto=1;
$num_filas=7;
$dias_mes= date('t', mktime(0,0,0, $mes, 1, $year)); $tabla='<table border="1" width="80%" align="center"><tr>';
$tabla.='<thead><tr><th>Lunes</th><th>Martes</th><th>Miercoles</th><th>Jueves</th><th>Viernes</th><th>Sabado</th><th>Domingo</th></tr></thead><tr>';
for($i=1;$i<=$dias_mes+($dia_num-1);$i++)
{
if ($i>=$dia_num){
$fecha_acum="SELECT fecha,sum(horas) from (SELECT * FROM reporte_horas ORDER BY DAY(fecha)) reporte_horas where DAY(fecha)=".($i-($dia_num-1))." AND MONTH(fecha)=MONTH(curdate()) AND YEAR(fecha)=YEAR(CURDATE())group by fecha";
$tabla.="<td>".$resultado2[1]."</td>";
}else{
$tabla.="<td> </td>";
}
if($salto==$num_filas){
$tabla.="</tr><tr>";
$salto=1;
}else{
$salto++;
}
}
$tabla.="</tr></table>";
echo $tabla;
?>
</body>
</html>
Algunas correciones...
el dia en que inicia el mes lo estaba calculando mal, estuve leyendo y es necesario colocar la fecha con el primer dia del mes, para hallar exactamente cuando inicia
esa fue la mas importante... revisalo