So I need my SQL table to be downloadable. Right now my php file creates an excel file and forces a download but the excel file just has a large array with the table's data inside it.
Here is my code
$sql = mysql_query("SELECT * FROM table");
while ($row_user = mysql_fetch_assoc($sql))
{ $userinfo[] = $row_user;
print_r($row_user);
header("Content-Disposition: attachment; filename=\"papi.xls\"");
header("Content-Type: application/vnd.ms-excel;");
header("Pragma: no-cache");
header("Expires: 0");
$file = fopen("php://output","w");
foreach($userinfo as $data)
{
fputcsv($file,explode(',',$data),"\t");
}
fclose($file);
}
Any help would be greatly appreciated, thank you in advance.