Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/04/2012, 11:36
jorudico
 
Fecha de Ingreso: abril-2012
Mensajes: 4
Antigüedad: 12 años
Puntos: 0
Respuesta: Problema para llenar una Grilla con PHP

No pude editar el mensaje, así que coloco el código acá




<?php
if(($_POST['mes']!="") and ($_POST['año']!=""))
{
$sql="select a.nombre , ap_paterno , ap_materno , a.rut, b.nombre , c.nombre,d.id_persona
from persona_m a , empresa_m b , funcion_m c , asistencia_t d where a.estado = 1" ;
$sql .= " and a.id_empresa = b.id and a.id_funcion = c.id and a.id = d.id_persona and d.fecha_ingreso between $mes1 and $mes2 group by d.id_persona";

$result=mysql_query($sql,$link);
$numero = mysql_num_rows($result);
echo $numero;
}

else {
?>
<script language='JavaScript'>
alert("Ingrese Fecha !")
</script>
<?php
$var = 0;
}

?>
<div id="Layer_tabla" align="center" style="OVERFLOW-Y: scroll; WIDTH: 920px; TOP: 400px; HEIGHT: 174px">

<div align="center">
<table BORDER="2" align="center" CELLPADDING="2">
<TR>
<TD width="119"> &nbsp; <B>Nombre </B></TD>
<TD width="135"> &nbsp; <B>Ap_Paterno </B></TD>
<TD width="135"> &nbsp; <B>Ap_Materno </B></TD>
<TD width="61"> &nbsp; <B>Rut </B></TD>
<TD width="166"> &nbsp; <B>Empresa </B></TD>
<TD width="135"> &nbsp; <B>Cargo </B></TD>
<TD width="15"> &nbsp; <B>1 </B></TD>
<TD width="15"> &nbsp; <B>2 </B></TD>
<TD width="10"> &nbsp; <B>3 </B></TD>
<TD width="10"> &nbsp; <B>4 </B></TD>
<TD width="10"> &nbsp; <B>5 </B></TD>
<TD width="10"> &nbsp; <B>6 </B></TD>
<TD width="10"> &nbsp; <B>7 </B></TD>
<TD width="10"> &nbsp; <B>8 </B></TD>
<TD width="10"> &nbsp; <B>9 </B></TD>
<TD width="10"> &nbsp; <B>10 </B></TD>
<TD width="10"> &nbsp; <B>11 </B></TD>
<TD width="10"> &nbsp; <B>12 </B></TD>
<TD width="10"> &nbsp; <B>13 </B></TD>
<TD width="10"> &nbsp; <B>14 </B></TD>
<TD width="10"> &nbsp; <B>15 </B></TD>
<TD width="10"> &nbsp; <B>16 </B></TD>
<TD width="10"> &nbsp; <B>17 </B></TD>
<TD width="10"> &nbsp; <B>18 </B></TD>
<TD width="10"> &nbsp; <B>19 </B></TD>
<TD width="10"> &nbsp; <B>20 </B></TD>
<TD width="10"> &nbsp; <B>21 </B></TD>
<TD width="10"> &nbsp; <B>22 </B></TD>
<TD width="10"> &nbsp; <B>23 </B></TD>
<TD width="10"> &nbsp; <B>24 </B></TD>
<TD width="10"> &nbsp; <B>25 </B></TD>
<TD width="10"> &nbsp; <B>26 </B></TD>
<TD width="10"> &nbsp; <B>27 </B></TD>
<TD width="10"> &nbsp; <B>28 </B></TD>
<TD width="10"> &nbsp; <B>29 </B></TD>
<TD width="10"> &nbsp; <B>30 </B></TD>
<TD width="10"> &nbsp; <B>31 </B></TD>
</TR>

<?php

$fechaInicio=$_POST['input1'];
$diaInicio = substr($fechaInicio, 0, 2);
$mesInicio = substr($fechaInicio, 3, 2);
$anoInicio = substr($fechaInicio, 6, 10);
// fecah del sistema
$diaActual = date ("d");
$mesActual = date ("m");
$anioActual = date ("Y");
if ($var != "0")
{

///////////////////////////////////////////////llena los datos del usuario ///////////////////////////////////////////////////
while($row = mysql_fetch_array($result))
{
?>
<TR>
<TD width="119"><?php echo $row["0"]; ?></TD>
<TD width="135"><?php echo $row["1"]; ?></TD>
<TD width="135"><?php echo $row["2"]; ?></TD>
<TD width="61"><?php echo $row["3"]; ?></TD>
<TD width="166"><?php echo $row["4"]; ?></TD>
<TD width="135"><?php echo $row["5"]; ?></TD>
<?php
$id_usuario = $row["6"]; // rescato el id

?>

<?php
//////////// // genero una segunda consulta para llenar lso dias ///////////////////
$sql="SELECT id_persona, fecha_ingreso, fecha_salida FROM asistencia_t";
$sql="WHERE fecha_ingreso between $mes1 and $mes2 order by fecha_ingreso ";

if($result_l=mysql_query($sql,$link))
{
if($num_l=mysql_num_rows($result_l))
{
while($row=mysql_fetch_row($result_l))
{
$id_2 =$row[0];
$fecha_in =$row[1];
$fecha_sal =$row[2];
$solodia = substr($fecha_in,9,2); // Se guarda el dia
if ( $id_usuario == $id_2)
{
for ( $dias=1; $dias <= 31; $dias++)
{

if ($dias == $solodia )
{

?> <TD width="15"><?php echo "/"; ?></TD>
<?php

}//Fin si ($dias == $solodia )
else
{
?> <TD width="15"><?php echo "x"; ?></TD>
<?php


}// fin else
}// fin for
}//din si
}// fin si $num


}//fin si
} // fin wuile $result_l
} //fin while
}//fin if var

?>
</TR>
</table>
</div>
</div>