I got a nice snippet that runs a query on a table and prints it into an csv format. I've got just one problem with that snippet: Some of the data in the rows is multi line and not a single word.
Now what happening is that the export looks like that:
Msg Name Phone
Message just goes over name and phone and not 'limited' only to message My Name 1800080808
(I want the value of 'msg' to be inside the msg cube and not go all over name and phone.)
Do you have any idea how could I set the whole phrase of a value inside one box?
Snippet:
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].";";
$i++;}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].";";
}
$csv_output .= "\n";
}
$filename = $file."_".date("d-m-Y_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
Thanks in advance!