Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/04/2013, 15:00
mariomb19
 
Fecha de Ingreso: mayo-2012
Ubicación: Caracas
Mensajes: 53
Antigüedad: 11 años, 11 meses
Puntos: 1
Pregunta Como recorrer todos los datos de una consulta

Buenas esoty haciendo una proyecto para la uni y tengo una gran duda como recorro completamente la la tabla, para uqe me arroje en el excel todos los datos que les pido por esa fecha por ejemplo pongo 2013-01-22 y 2013-01-24, pero me sale solo el pŕimero que encuentra del 22 y no todos. Gracias

consultaEstadistica.php
Código PHP:
Ver original
  1. <form action="excel.php" id="form1" name="form1" method="post" >
  2.             <input name="opcion" id="opcion" type="hidden" />
  3.             <input name="status" id="status" type="hidden" value="<?php echo $_POST['status']; ?>"/>
  4.             <div id="content" style="width: 915px;">
  5.             <h1>Modulo de Generación de Estadística</h1>       
  6.                     <strong>Fecha de inicio:</strong>
  7.                         <input type="text" name="fecha_inicio" id="fecha_inicio"
  8.                         onClick="ShowCalendario(event)" size="10">  
  9.                     <strong>Fecha Fin:</strong>
  10.                     <input ="text" name="fecha_fin" id="fecha_fin"
  11.                         onClick="ShowCalendario(event)" size="10">
  12.                     <p></p>
  13.                     <p></p>
  14.                    
  15.                     <input type="submit" name="Buscar"id="Buscar" value="Buscar" >
  16.                    
  17.             </div>
  18.             </form>

excel.php

Código PHP:
Ver original
  1. <?php
  2.    
  3.     $fecha_inicio= $_REQUEST['fecha_inicio'];
  4.     $fecha_fin= $_REQUEST['fecha_fin'];
  5.  
  6.     if ($fecha_inicio=='0000-00-00') {
  7.         //echo $fecha_inicio;
  8.         }   else {
  9.         $fecha_inicio=date("Y-m-d",strtotime($fecha_inicio));
  10.         //echo $fecha_inicio;
  11.     }
  12.     if ($fecha_fin=='0000-00-00') {
  13.         //echo $fecha_fin;
  14.         }   else {
  15.         $fecha_fin=date("Y-m-d",strtotime($fecha_fin));
  16.         //echo $fecha_fin;
  17.     }  
  18.  
  19.     include "../PHP/conexion.php";
  20.     $registros=mysql_query("select cod_dea, fecha_inicio, fecha_fin, entregas_2do,
  21.     entregas_3ro, entregas_4to, entregas_5to, entregas_6to, total_entregas, direccion,
  22.     plantel, estado, municipio, director, tlf_director, lugar_entrega
  23.   from cronograma_temp where like fecha_inicio >= STR_TO_DATE('$fecha_inicio','%Y-%m-%d')
  24.   AND fecha_fin<= STR_TO_DATE('$fecha_fin','%Y-%m-%d')",$conexion) or
  25.     die("Problemas en el select:".mysql_error());
  26.  
  27.         if ($reg=mysql_fetch_array($registros))
  28.         {
  29.             header('Pragma: public');
  30.             header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past    
  31.             header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  32.             header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  33.             header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
  34.             header('Pragma: no-cache');
  35.             header('Expires: 0');
  36.             header('Content-Transfer-Encoding: none');
  37.             header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera
  38.             header('Content-type: application/x-msexcel'); // This should work for the rest
  39.             header('Content-Disposition: attachment; filename="nombre.xls"');
  40.  
  41.             echo $reg['cod_dea'];
  42.             echo $reg['fecha_inicio'];
  43.             echo $reg['fecha_fin'];
  44.             echo $reg['entregas_2do'];
  45.             echo $reg['entregas_3ro'];
  46.         }
  47.     else
  48.     {
  49.         echo "No existe eventos registrado con esas fechas.";
  50.     }
  51.     mysql_close($conexion);
  52.    
  53. ?>