I want how can I add newly one new row at the top of the csv file becase in my csv file output its populated with data from database and what I want to happen is that I want to add corresponding column names for every type of data.
Here is my code as of now:
<?php
include 'database.php';
$db = new database();
$data = $db->exportdatabase();
$file = fopen('php://output', 'w');
foreach ($data as $items)
{
fputcsv($file, $items, ',');
}
header('Content-Description: File Transfer');
header("Content-Type: application/csv") ;
header("Content-Disposition: attachment; filename=data.csv");
header("Expires: 0");
fclose($file);
exit;
?>
Here is my csv data looks like