Ver Mensaje Individual
  #6 (permalink)  
Antiguo 06/02/2012, 22:01
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Generar archivo txt a partir de pagina php

hola amigos


ya desde una pagina php exporto a un txt ahora necesito imprimir en el archivo txt

por favor me pueden indicar

Código PHP:
Ver original
  1. <div><a href="index.php?controller=user_&amp;accion=reporte">exportar</a></div>

Código PHP:
Ver original
  1. /*----------------------  Funcion Exportar Listado ----------------------*/
  2. function reporte()
  3. {
  4.     require 'models/user_Model.php';
  5.  
  6.               $ls = new Users();
  7.               $fl = $ls -> list_allusers($db);   
  8.  
  9.     require 'views/reporte.php';
  10. }


este es el archivo reporte.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. $filecontent="Aqui va el mensaje de texto ... ";
  4. $downloadfile="nombre.txt";
  5.  
  6. header("Content-disposition: attachment; filename=$downloadfile");
  7. header("Content-Type: application/force-download");
  8. header("Content-Transfer-Encoding: binary");
  9. header("Content-Length: ".strlen($filecontent));
  10. header("Pragma: no-cache");
  11. header("Expires: 0");
  12.  
  13. ?>
  14.  
  15. Nº   Nombre     Usuario      Estado
  16. <?php
  17. $cont = 1;
  18. foreach($fl as $field)
  19. {
  20. echo $cont;
  21.        
  22.  
  23.    
  24.         $cont++;
  25.        
  26.         }
  27.  
  28.     ?>