I have some code here that exports to a csv file. I connected to the database and saw that there was well over 30 entries or so. But I'm only getting one in the csv file. The top part gets the headings for the file and the bottom the values, the values array is only returning one array and putting it into the file. I'm not sure what's causing this issue. Anny suggestions would be greatly appreciated.
<?php
$FileName = "mro_export_".date("Y-m-d_H-i",time()).".csv";
$file = fopen($FileName,"w");
$sql = mysql_query("SELECT * FROM `$table` LIMIT 11");
$row = mysql_fetch_assoc($sql);
// Save headings alon
$HeadingsArray=array();
foreach($row as $name => $value){
$HeadingsArray[]=$name;
}
fputcsv($file,$HeadingsArray);
$ValuesArray=array();
foreach($row as $name => $value){
$ValuesArray[]=$value;
}
fputcsv($file,$ValuesArray);
fclose($file);
header("Location: $FileName");
?>