Files
Assassins-Mission-Control/admin-tools/export-csv.php
T
jcreek 8a2f8b629a Further admin tools
There’s a bug where the CSV export isn’t putting anything into the CSV
2014-08-22 16:47:39 +01:00

36 lines
660 B
PHP

<?php
// Download the file
$filename = "myFile.csv";
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
// Fetch Record from Database
$output = "";
$table = "usersfinal";
$sql = mysql_query("select * from $table");
$columns_total = mysql_num_fields($sql);
// Get The Field Name
for ($i = 0; $i < $columns_total; $i++) {
$heading = mysql_field_name($sql, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";
// Get Records from the table
while ($row = mysql_fetch_array($sql)) {
for ($i = 0; $i < $columns_total; $i++) {
$output .='"'.$row["$i"].'",';
}
$output .="\n";
}
print $output;
exit;
?>