Hi, i have a code to download the data from database to excel file. The problem is that, everything is working fine. But, actually with my code, the field name is not coming. I want to download the filed name too at the top of each column. So, i m giving my code below and tell me where should i change and what code should written do access the field name too.
[PHP]
<?php
include("config.php");
include("connect.php");
$sql = "SELECT * FROM employee";
$result = mysql_query($sql) or die(mysql_erorr());
$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>".implode("</td><td>", $row)."</td></tr>";
}
$tsv = implode("\r\n",$tsv);
$html = "<table>".implode("\r\n", $html)."</table>";
$fileName = 'mysql_to_excel.xls';
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment; filename = $fileName");
echo $tsv;
mysql_close();
?>
[/PHP]