Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/11/2006, 19:29
Avatar de a83
a83
 
Fecha de Ingreso: noviembre-2005
Ubicación: Santiago de chile
Mensajes: 637
Antigüedad: 21 años
Puntos: 1
pasar los datos de msql a excel

como puedo hacer esto tengo el siguiente cod qpero me manda errores

Código PHP:
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/rymchile/public_html/php/Personal/excel.php on line 5

Warning
: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/rymchile/public_html/php/Personal/excel.php on line 11

Warning
: Cannot modify header information - headers already sent by (output started at /home/rymchile/public_html/php/conexion.php:2) in /home/rymchile/public_html/php/Personal/excel.php on line 35

Warning
: Cannot modify header information - headers already sent by (output started at /home/rymchile/public_html/php/conexion.php:2) in /home/rymchile/public_html/php/Personal/excel.php on line 37

Warning
: Cannot modify header information - headers already sent by (output started at /home/rymchile/public_html/php/conexion.php:2) in /home/rymchile/public_html/php/Personal/excel.php on line 38

Warning
: Cannot modify header information - headers already sent by (output started at /home/rymchile/public_html/php/conexion.php:2) in /home/rymchile/public_html/php/Personal/excel.php on line 39
no matching records found 


codigo


Código PHP:
<?php
include("../conexion.php");     
$sql="select * from ingreo_personal order by FECHA desc";
//$result = conexionl($sql); 
$count = mysql_num_fields($result);

for (
$i = 0; $i < $count; $i++){
    
$header .= mysql_field_name($result, $i)."\t";
}

while(
$row = mysql_fetch_row($result)){
  
$line = '';
  foreach(
$row as $value){
    if(!isset(
$value) || $value == ""){
      
$value = "\t";
    }else{

      
$value = str_replace('"', '""', $value);

      
$value = '"' . $value . '"' . "\t";
    }
    
$line .= $value;
  }
  
$data .= trim($line)."\n";
}

  
$data = str_replace("\r", "", $data);


if (
$data == "") {
  
$data = "\nno matching records found\n";
}


header("Content-type: application/octet-stream");

header("Content-Disposition: attachment; filename=clientes.xls");
header("Pragma: no-cache");
header("Expires: 0");

echo 
$header."\n".$data; 
?> 
:arriba: