I am trying to generate an XLS file from a table in a MySQL DB, but the Excel file is not properly formatted & given error when the Excel file generated \"The file which you
Sl No ";
for ( $i = 0; $i < $numcolumn; $i++ ) {
$msg.="";
$msg.= mysql_field_name($res, $i); //will store column name of the table to msg variable
$msg.=" ";
}
$msg.=" ";
$i=0;
$count=1; //used to print sl.no
while($row=mysql_fetch_array($res)) //fetch all the row as array
{
$msg.="".$count." ";
for($i=0;$i< $numcolumn;$i++)
{
$var=$row[$i]; //will store all the values of row
$msg.="".$var." ";
}
$count=$count+1;
$msg.=" ";
}
$msg.="";
echo $msg; //will print the content in the exel page
}
?>
Click to download"; //link to download file
?>