So here is the code I currently have for exporting a specific table to .csv format. It works perfectly so far, as in it downloads the file and formats the data how I would like it. However it doesn't display the Column names
ex: It currently shows
1 Jones Matt
2 Smith John
3 Doe Jane
I would like it to show:
ID Last_Name First_Name
1 Jones Matt
2 Smith John
3 Doe Jane
<?php
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=applications.csv");
header("Pragma: no-cache");
header("Expires: 0");
ini_set('display_errors',1);
$private=1;
error_reporting(E_ALL ^ E_NOTICE);
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$query = "SELECT * FROM applications";
$select_c = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($select_c, MYSQL_ASSOC))
{
$result.="{$row['ID']},";
$result.="{$row['LAST_NAME']},";
$result.="{$row['FIRST_NAME']},";
$result.="{$row['ORGANIZATION']},";
$result.="{$row['TITLE']},";
$result.="\n";
}
echo $result;
?>