<?php
ob_start("ob_gzhandler");
include("../config/dbconfig.php");//connect db
$result = mysql_query('select * from salesreport');
$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=resume.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>

Is this supposed to represent a solution or a problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.