Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/04/2013, 15:22
alex1084
 
Fecha de Ingreso: abril-2008
Ubicación: El Salvador
Mensajes: 736
Antigüedad: 16 años
Puntos: 47
Respuesta: Como recorrer todos los datos de una consulta

Tendrias que meterlo dentro de un bucle for, foreach o while, pero debes cambiar un poco la estructura a algo como esto.

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.         while($reg=mysql_fetch_array($registros))
  28.        {
  29.             $echo  .= $reg['cod_dea'];
  30.             $echo .= $reg['fecha_inicio'];
  31.             $echo .= $reg['fecha_fin'];
  32.             $echo .= $reg['entregas_2do'];
  33.             $echo .= $reg['entregas_3ro'];
  34.         }
  35.             header('Pragma: public');
  36.             header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past    
  37.             header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  38.             header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  39.             header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
  40.             header('Pragma: no-cache');
  41.             header('Expires: 0');
  42.             header('Content-Transfer-Encoding: none');
  43.             header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera
  44.             header('Content-type: application/x-msexcel'); // This should work for the rest
  45.             header('Content-Disposition: attachment; filename="nombre.xls"');
  46.             echo $echo;
  47.     else
  48.     {
  49.         echo "No existe eventos registrado con esas fechas.";
  50.     }
  51.     mysql_close($conexion);
  52.    
  53. ?>

Aunque te recomendaria que uses una clase, hay muchas clases ya hechas para exportar a excel ...