I am currently developing an App for my school to record Class Cleanliness Results for each class, so I need to convert the results collated in MySQL table into Microsoft Excel using PHP, preferably also able to be opened by a Android OS Phone.
I used the following PHP code:
<?PHP
$mysqli_user = "(user)";
$mysqli_password = "(password)";
$mysqli_host = "(host)";
$mysqli_database = "(database)";
$filename = "grading_results_" . time() . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$link = mysqli_connect($mysqli_host,$mysqli_user,$mysqli_password,$mysqli_database);
$query = 'SELECT * FROM (table_name)';
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_row($result)){
print implode("\t", $row) . "
";
}
mysqli_close($link);
?>
This is how my table looks like in phpMyAdmin:
https://www.dropbox.com/s/7pr3gh06zta5d8u/Snip20150618_2.png?dl=0
This is how the Excel file looks like after I used this code to convert.
https://www.dropbox.com/s/571m9lfj64tklpc/Snip20150618_3.png?dl=0
Why is there no columns and rows? I need the Excel file to be exactly the same formatting and style as the table in phpMyAdmin. Can anyone help edit my code instead of providing me a brand new code?
Thanks in advance for your answers!