can anyone help me whats wrong with these code, im supposed to convert the data to excel but the problem is wen it opens in excel there is only blank and it opens to excel applications instead of one and i cant figure out what's wrong i just started to study converting these i would really appreciate the help
<?php
require_once "db_connect.php";
$query = "SELECT *
FROM customer";
$result = mysql_query($query) or die(mysql_error());
while($data = mysql_fetch_array($result, MYSQL_NUM))
{
$pattern[] = implode("\t", $data);
$html[] = "<tr><td>" . implode("</td><td>", $data) . "</td></tr>";
}
$pattern = implode("\r\n", $pattern);
$html = "<table>" . implode("\r\n", $html) . "</table>";
$file_name = 'reports.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file_name")
?>