hello,
I need to know what to do with a csv export in which i would like the entire field content to be enclosed with quotes. My problem is with fields that include commas.
I think i'm close with this, but how would i tell it to enclose all fields with quote?
<?php
include("config.php");
$connect = mysql_connect("$user_hostname", "$user_username", "$user_password");
mysql_select_db("$user_database", $connect);
$F = fopen('entrants_full.csv' , 'w'); // open for write
$delim = ",";
$res = mysql_query("SELECT * FROM xxxxx where field = xxx");
$numfields = mysql_num_fields($res);
for($x=0;$x<$numfields;$x++){
$titles[] = mysql_field_name($res, $x);
}
fwrite($F, join($delim, $titles) . "\n");
while ($row = mysql_fetch_row($res)) {
fwrite($F, join($delim, $row) . "\n");
}
fclose($F);
header("Content-Type: text/plain");
header("Pragma: cache");
header('Content-Disposition: attachment; filename=entrants_full.csv');
header("Expires: 0");
readfile('entrants_full.csv');
?>
should i do a search and replace in the field before it hite the database, or should i just tell this script to enclose all fields with quotes?
-Michael