mirror of
https://github.com/jcreek/Assassins-Mission-Control.git
synced 2026-07-12 18:43:43 +00:00
8a2f8b629a
There’s a bug where the CSV export isn’t putting anything into the CSV
36 lines
660 B
PHP
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;
|
|
?>
|