Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/05/2013, 10:27
marianomartelli
 
Fecha de Ingreso: agosto-2012
Ubicación: Barcelona
Mensajes: 243
Antigüedad: 11 años, 9 meses
Puntos: 1
Comparar si una fecha ingresada es igual a la de la base de datos

Hola a todos,
A ver si alguien me puede echar una mano.
Necesito que al ingresar una fecha aaaa-mm-dd me encuentre las que son iguales de la base de datos y me las muestre.
He probado con este codigo pero tengo problemas

<?php
$fechareg ="";
@$fechareg = $_GET['fechareg'];
include("conexion.php");

$consulta=("SELECT * FROM dato_empresa WHERE fechareg= '$fechareg' ORDER BY empresa ");
$datos=mysql_query($consulta,$conexion);
$num_rows=mysql_num_rows($datos);




?>



<?php
//AL PRINCIPIO COMPRUEBO SI HICIERON CLICK EN ALGUNA PÁGINA
if(isset($_GET['page']))
{
$page= $_GET['page'];
}
else
{
//SI NO DIGO Q ES LA PRIMERA PÁGINA
$page=1;
}



//ACA SE DECIDE CUANTOS RESULTADOS MOSTRAR POR PÁGINA , EN EL EJEMPLO PONGO 15
$rows_per_page= 15;

//CALCULO LA ULTIMA PÁGINA
$lastpage= ceil($num_rows / $rows_per_page);

//COMPRUEBO QUE EL VALOR DE LA PÁGINA SEA CORRECTO Y SI ES LA ULTIMA PÁGINA
$page=(int)$page;

if($page > $lastpage)
{
$page= $lastpage;
}

if($page < 1)
{
$page=1;
}

//CREO LA SENTENCIA LIMIT PARA AÑADIR A LA CONSULTA QUE DEFINITIVA
$limit= 'LIMIT '. ($page -1) * $rows_per_page . ',' .$rows_per_page;

//REALIZO LA CONSULTA QUE VA A MOSTRAR LOS DATOS (ES LA ANTERIO + EL $limit)
$consulta .=" $limit";
$empresas=mysql_query($consulta, $conexion);



$tr_empresas="";


while($row = mysql_fetch_assoc($empresas))



{


$tr_empresas.="



<tr>
<td align='center'>".$row['empresa']."</td>
<td align='center'>".$row['direccion']."</td>
<td align='center'>".$row['fechareg']."</td>


<td colspan='6'><hr>
</tr>

";
}




?>


<style>
body{font-family:Arial, Helvetica, sans-serif; font-weight:bold;}
table.tabla_empresa{border:none;border-collapse:collapse}
table.tabla_empresa{background-color:#BFBFBF;width:100%;}
table.tabla_empresa th{background-color:#4D4D4D;color:#FFFFFF;border:1px solid #E6E6FA}
table.tabla_empresa td{background-color:#FFFFFF;}
</style>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name : OfficialWork
Description: A two-column, fixed-width design with dark color scheme.
Version : 1.0
Released : 20121012

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>listreg.php</title>
<link href="css/svuotatablas.css rel="stylesheet" type="text/css" media="screen" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/paginacion.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery/jquery.gallerax-0.2.js"></script>
<style type="text/css">

</style>
</head>
<body>

<h6> Listado por fecha de nuevos usuarios</h6>
Ingrese la fecha a buscar formato(aaaa-mm-dd)
<input type="date" size="32" value="" name="fechareg"/>
<a style="position:relative; margin: 0px 780px 0px;" href="admin.html" >Volver</a>


<br />
<div id= "centrar_tabla">
<table class='tabla_empresa'>
<tr>
<th>Empresa</th>
<th>Direccion</th>
<th>Fecha Registro</th>
</tr>
<?php echo $tr_empresas;?>
</table>

<?php
//UNA VEZ Q MUESTRO LOS DATOS TENGO Q MOSTRAR EL BLOQUE DE PAGINACIÓN SIEMPRE Y CUANDO HAYA MÁS DE UNA PÁGINA

if($num_rows != 0)
{
$nextpage= $page +1;
$prevpage= $page -1;

?><ul id="pagination-digg"><?php
//SI ES LA PRIMERA PÁGINA DESHABILITO EL BOTON DE PREVIOUS, MUESTRO EL 1 COMO ACTIVO Y MUESTRO EL RESTO DE PÁGINAS
if ($page == 1)
{
?>
<li class="previous-off">&laquo; Anterior</li>
<li class="active">1</li>
<?php
for($i= $page+1; $i<= $lastpage ; $i++)
{?>
<li><a href="listreg.php?page=<?php echo $i;?>"><?php echo $i;?></a></li>
<?php }

//Y SI LA ULTIMA PÁGINA ES MAYOR QUE LA ACTUAL MUESTRO EL BOTON NEXT O LO DESHABILITO
if($lastpage >$page )
{?>
<li class="next"><a href="listreg.php?page=<?php echo $nextpage;?>" >Siguiente &raquo;</a></li><?php
}
else
{?>
<li class="next-off">Siguiente &raquo;</li>
<?php
}
}
else
{

//EN CAMBIO SI NO ESTAMOS EN LA PÁGINA UNO HABILITO EL BOTON DE PREVIUS Y MUESTRO LAS DEMÁS
?>
<li class="previous"><a href="listreg.php?page=<?php echo $prevpage;?>">&laquo; Anterior</a></li><?php
for($i= 1; $i<= $lastpage ; $i++)
{
//COMPRUEBO SI ES LA PÁGINA ACTIVA O NO
if($page == $i)
{
?> <li class="active"><?php echo $i;?></li><?php
}
else
{
?> <li><a href="listreg.php?page=<?php echo $i;?>" ><?php echo $i;?></a></li><?php
}
}
//Y SI NO ES LA ÚLTIMA PÁGINA ACTIVO EL BOTON NEXT
if($lastpage >$page )
{ ?>
<li class="next"><a href="listreg.php?page=<?php echo $nextpage;?>">Siguiente &raquo;</a></li><?php
}
else
{
?> <li class="next-off">Siguiente &raquo;</li><?php
}
}
?></ul></div><?php
}

?>
</body>
</html>





En la espera

GRacias y saludos