A possible completion to your tutorial:
Dumping a MySQL table to Excel
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=MySQLdumo2Excel.xls");
header("Content-Description: Excel output");
$database = "test";
$table = "test";
mysql_connect("localhost", "", "")
or print ">>> MySQL-Error: ".mysql_errno()." -> ".mysql_error()."<br>\n";
mysql_select_db($database)
or print ">>> MySQL-Error: ".mysql_errno()." -> ".mysql_error()."<br>\n";
$query_text = "SELECT * FROM $table";
$result = mysql_query($query_text)
or print ">>> MySQL-Error: ".mysql_errno()." -> ".mysql_error()."<br>\n";
$fieldcounts = mysql_num_fields($result);
for($i = 0; $i < $fieldcounts; $i++) {
$fieldtype = mysql_fetch_field($result, $i);
echo "$fieldtype->name [$fieldtype->type]\t";
}
echo "\n";
while ($myrow = mysql_fetch_array($result)) {
for($i = 0; $i < $fieldcounts; $i++) {
$fieldname = mysql_field_name($result, $i);
echo "$myrow[$fieldname]\t";
}
echo "\n";
}
?>