One last thing and this code is complete.
I'm trying to add a header above the field names in the csv.
$result = mysqli_query($con,"SELECT * FROM amazon");
$num_fields = mysqli_num_fields($result);
$headers = array();
for ($i = 0; $i < $num_fields; $i++)
{
$headers[] = mysqli_fetch_field_direct($result, $i)->name;
}
$fp = fopen('amazon.csv', 'w');
if ($fp && $result)
{
$list = array (
array('TemplateType=Offer', 'Version=2014.0703')
);
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fputcsv($fp, $headers, "\t");
while ($row = mysqli_fetch_row($result))
{
fputcsv($fp, array_values($row), "\t");
}
}
Problem is I need a Tab separating the fields - not a comma.
So:
array('TemplateType=Offer', 'Version=2014.0703')
needs to be something else.
Maybe I'm overcomplicating this?
Any ideas?
Thanks
Ron