Ver Mensaje Individual
  #8 (permalink)  
Antiguo 24/01/2013, 11:04
facundojr07
 
Fecha de Ingreso: enero-2013
Mensajes: 64
Antigüedad: 11 años, 3 meses
Puntos: 0
Respuesta: Exportar a Excel tabla mysql

Ahí pude... lo que hice es crear un codigo nuevo en otra pagina

Código PHP:

<?php 
header
("Content-type: application/vnd.ms-excel" ) ; 
header("Content-Disposition: attachment; filename=estadisticas.xls" ) ; 
$servidor="localhost"
$user="root"
$pass=""
$db="bd_XXXX"
$tabla="bd_rtdmf"
mysql_connect($servidor,$user,$pass) ; 
mysql_select_db($db) ;

if(isset(
$_GET['df'])){
        
$DF $_GET['df'];
    }
$query=mysql_query("SELECT * FROM bd_rtdmf WHERE ID_N IN ('".$DF."')" ) ; 
$campos mysql_num_fields($query) ; 

$i=0
echo 
"<table><tr>"
while(
$i<$campos){ 
echo 
"<td>"mysql_field_name ($query$i) ; 
echo 
"</td>"
$i++; 

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

echo 
"</tr>"

echo 
"</table>";

?>
Y en otra página, donde va en link agregue

Código PHP:
<?php echo "<a href='pag-mysql-excel.php?df=000'>Exportar a Excel</a><br />"?>
Y me funciona OK. Gracias por intentar ayudarme. Saludos.