Hi there,
I am trying to allow users download a csv file from my website. This is as far as I have got with the code but it just opens a blank page and doesn't download anything.
Any advice?
[PHP]
<?php
require_once (MYSQL);
require_once ('mysqli_connect.php');
$q="SELECT * FROM table_name";$r =
@mysqli_query($dbc, $q);
$html = "<table>";$html .= "<tr><td>Song</td>";
$html .= "</tr>";
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$html .= "<tr><td>".$row."</td>";
$html .= "</tr>";}$html .= "</table>";
header("Content-Type: text/csv");
header("Content-Disposition: attachment;filename=yourfile.csv");
echo $html;
?>[/PHP]