1[This is the output] Trying to export SQL data as excel file by looping the array but failed to export the leading 0 of data.
I had tried to place single quote in the implode but still not working
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$user_query = mysqli_query($conn,$sql);
//echo $user_query;
// Write data to file
$flag = false;
while ($row = mysqli_fetch_assoc($user_query)) {
if (!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
echo implode("\t", =array_values($row)) . "\r\n";
}
Expect to implode with "\t'" with the single quote but still failed to export the leading 0