Here is my code
require_once('../dblog.php');
$row = ('SELECT year, make, model, vin from inventory');
$result = mysqli_query($mysqli, $row);
$fp = fopen("./file.csv", 'w');
while ($row = mysqli_fetch_row($result)) {
$list = array('year', 'make', 'model', 'vin');
fputcsv($fp, $list);
fputcsv($fp, $row);
}
fclose($fp);
mysqli_free_result($result);
mysqli_close($mysqli);
I am opening this file with notepad and the output I get is delimited with commas, however I need each field to be enclosed with double quotes. I rtfm and tried a bunch of different syntaxes for fputcsv function. I am using php 5.2+. On a strange? note $row[3] has double quotes?! but no other entires do, the mysqli database does not reflect the value with double quotes.
Also is there a good viewer to use instead of notepad to check my csv files for correct syntax. I don't have excel.
Thanks for your input.