Ver Mensaje Individual
  #15 (permalink)  
Antiguo 07/09/2011, 07:40
Avatar de stuart_david3
stuart_david3
 
Fecha de Ingreso: agosto-2011
Mensajes: 215
Antigüedad: 12 años, 8 meses
Puntos: 1
Respuesta: Consulta rango entre 2 fechas!!!...

Ala beisbooooooooooooooooooooool!!! Muchísimas gracias, ya quedo aqui esta el código ya funcionando, soy tan feliz T_T...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" href="css/sunny/jquery-ui-1.8.13.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js"></script>
<script type="text/javascript">

$(function() {
$( ".datepicker" ).datepicker();
});
</script>
<body>
<form id="form" name="form" method="post">
Fecha Inicio:
<input type="text" name="fechaIni" class="datepicker">
<br>
Fecha Final:
<input type="text" name="fechaFin" class="datepicker">
<br>
<input type="submit" value="Consultar">
</form>
<h1>Consultas</h1>

<?php
function js2PhpTime($jsdate){
if(preg_match('@(\d+)/(\d+)/(\d+)\s+(\d+):(\d+)@', $jsdate, $matches)==1){
$ret = mktime($matches[4], $matches[5], 0, $matches[1], $matches[2], $matches[3]);
//echo $matches[4] ."-". $matches[5] ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3];
}else if(preg_match('@(\d+)/(\d+)/(\d+)@', $jsdate, $matches)==1){
$ret = mktime(0, 0, 0, $matches[1], $matches[2], $matches[3]);
//echo 0 ."-". 0 ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3];
}
return $ret;
}
$fechaIni=$_POST['fechaIni'];
$fechaFin=$_POST['fechaFin'];
//$fechaMySQLFin = $_POST[implode( '-', array_reverse( explode( '/', $fechaFin ) ) )] ;
$Inicio=date("Y-m-d", js2PhpTime($fechaIni));
$Final=date("Y-m-d", js2PhpTime($fechaFin));
$conectar=mysql_connect('localhost','root','');
if($conectar=NULL)
{
printf("Error al conectar a la Base de datos");
}

mysql_select_db('registro');
echo $fechaIni;
$resultado=mysql_query("SELECT RPEREGASIS, FECREGASIS, MIN( HORREGASIS ) AS entrada, MAX( HORREGASIS ) as salida
FROM registro WHERE FECREGASIS='$Inicio' OR BETWEEN '$Inicio' AND '$Final' GROUP BY RPEREGASIS, FECREGASIS");

if($row=mysql_fetch_array($resultado)){
echo "<table border='1' align='center'>\n";
echo "<tr><td>RPE Del Empleado</td><td>Fecha de Registro</td><td>Hora de Entrada</td><td>Hora de Salida</td></tr>\n";
do{

echo "<tr><td>".$row["RPEREGASIS"]."</td><td>".$row["FECREGASIS"]."</td><td>".$row["entrada"]."</td><td>".$row["salida"]."</td></tr> \n";
}while($row=mysql_fetch_array($resultado));
echo "</table>\n";
}
else{
echo "<center>No existen registros para el rango de esas fechas</center>";
}

?>


</body>
</html>