I didn't find anything helpful to me using the search button so I shall post.
Below is the code I got from a tutorial on this subject. It simply prints out the data on the screen. There is no way to save the data as an excel spredasheet. Why? Many thanks.
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
define(db_host, "localhost");
define(db_user, "wwww");
define(db_pass, "cccc");
define(db_link, mysql_connect(db_host,db_user,db_pass));
define(db_name, "ops_db");
mysql_select_db(db_name);
?>
<?php
$select = "SELECT * FROM Actual_Noon";
$export = mysql_query($select);
$fields = mysql_num_fields($export);
?>
<?php
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}
?>
<?php
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);
?>
<?php
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
?>
<?php
print "$header\n$data";
?>