Ver Mensaje Individual
  #4 (permalink)  
Antiguo 04/05/2008, 16:10
Avatar de jaronu
jaronu
 
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Re: Ayuda con FPDF

Código PHP:
<?php 

//aqui la conexion a la BD

/******************************************** 
Write the query, call it, and find the number of fields 
/********************************************/ 
$qry =mysql_query("SELECT * from descargas"); 

$campos mysql_num_fields($qry);   
$i=0;   

/******************************************** 
Extract field names and write them to the $header 
variable 
/********************************************/
ob_start(); 
echo 
"&nbsp;<center><table border=\"1\" align=\"center\">"
echo 
"<tr bgcolor=\"#336666\"> 
  <td><font color=\"#ffffff\"><strong>ID</strong></font></td> 
  <td><font color=\"#ffffff\"><strong>NOMBRE</strong></font></td> 
  <TD><font color=\"#ffffff\"><strong>DESCRIPCION</strong></font></TD> 
  <td><font color=\"#ffffff\"><strong>RUTA</strong></font></td> 
  <td><font color=\"#ffffff\"><strong>TIPO</strong></font></td> 
  <td><font color=\"#ffffff\"><strong>TAMAÑO</strong></font></td>
  <td><font color=\"#ffffff\"><strong>CATEGORIA</strong></font></td>
</tr>"

while(
$row=mysql_fetch_array($qry)) 
{   
    echo 
"<tr>";   
     for(
$j=0$j<$campos$j++) {   
         echo 
"<td>".$row[$j]."</td>";   
     }   
     echo 
"</tr>";         
}   
echo 
"</table>"

$reporte ob_get_clean();
/******************************************** 
Set the automatic downloadn section 
/********************************************/

header("Content-type: application/vnd.ms-excel"); 
header("Content-Disposition: attachment; filename=consulta.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0");  

echo 
$reporte


?>
Un saludo, espero que te sirva, aunque sea temporalmente