Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/09/2008, 09:33
kike278
 
Fecha de Ingreso: abril-2008
Mensajes: 62
Antigüedad: 16 años, 10 meses
Puntos: 1
Pregunta Consulta por rango de fechas!

Hola Buen Dia

tengo un pequeño problema con una consulta por rango de fechas las cuales son obtenidas mediante un formulario, tengo el siguiente codigo pero no me muestra resultados y tampoco ningun error, las fechas estan almacenadas en campo date aa-mm-dd 00:00:00

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Documento sin t&iacute;tulo</title>
</
head>
<
body>
<
form id="form1" name="form1" method="post" action="resbus.php">
  <
label>
  <
input name="fecha1" type="text" id="fecha1" />
  </
label>
  <
br />
  <
label>
  <
input name="fecha2" type="text" id="fecha2" />
  </
label>
  <
br />
  <
label>
  <
input type="submit" name="Submit" value="Enviar" />
  </
label>
  <
br />

</
form>
</
body>
</
html

Código PHP:
<html>
<head>
<title>Problema</title>
</head>
<body>
<?php
$conexion
=mysql_connect("localhost","root","kike278") or
  die(
"Problemas en la conexion");
mysql_select_db("contratacion",$conexion) or
  die(
"Problemas en la seleccion de la base de datos");  
$registros=mysql_query("Select * from principal where fechacaptura >= '$fecha1' AND fechacaptura <= '$fecha2'"$conexion) or
  die(
"Problemas en el select".mysql_error());
if (
$reg=mysql_fetch_array($registros))
{
  echo 
"No.Nomina:".$reg['nonomina']."<br>";
  }
else
{
  echo 
"No existe ningun registro.";
}
mysql_close($conexion);
?>
</body>
</html>