Write a piece of code that does this.
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=table.csv");
header("Content-Transfer-Encoding: binary");
// The headers may need to be played with
$db = mysql_connect($host, $user, $pass);
// Note: Table should come in from outside this script.
$query = "SELECT * FROM $table";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_row) {
for ($i = 0 ; $i < count($row); $i++) {
if (!is_string($row[$i])) {
print $row[$i].",";
}
else {
print "\"".$row[$i]."\",";
}
}
print "\n";
}
?>
That should walk through all rows in a table and display them in CSV format. The headers at the top should force the file generated to be downloaded.