14/03/2005, 11:51
|
| | | Fecha de Ingreso: marzo-2005
Mensajes: 180
Antigüedad: 19 años, 8 meses Puntos: 0 | |
Yo uso esto y me jala chidito
<?
define(db_host, "$DbServer");
define(db_user, "$DbUsuario");
define(db_pass, "$DbClave");
define(db_link, mysql_connect(db_host,db_user,db_pass));
define(db_name, "$DbNombre");
mysql_select_db(db_name);
$select = "SELECT * FROM registros";
if ($Id){
$select .= " WHERE asesor='$Id'";
}
$select .= " ORDER BY $Order";
$export = mysql_query($select);
$fields = mysql_num_fields($export);
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($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 = "\n No se encontraron registros!\n";
}
$Dia =(date("d"));
$Mes =(date("m"));
$Ano =(date("Y"));
$Hora =(date("H"));
$Minutos =(date("i"));
$AmPm =(date("A"));
$NombreArchivo = "registro_".$Dia."_".$Mes."_".$Ano.".xls";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$NombreArchivo");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
?> |