export to csv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone, I have a small problem when exporting mysql into csv format.

 

The export works fine. The problem is, if the mysql table has a carriage
return, opening the csv file in excel will display a square box where the
carriage return is.

 

Displaying the table on a web page is fine.

 

Thanks for any help.

 

Haig

 

<?php

 

$csv_output = 'column1';

$csv_output .= "\015\012";

$result = mysql_query("select * from table"); 

while($row = mysql_fetch_array($result)) 

       {

              $csv_output .= '"'.$row[column1].'"';

              $csv_output .= "\015\012";

       }

header("Content-type: application/vnd.ms-excel");

header("Content-disposition:  attachment; filename=" .

date("Y-m-d")."_my_report".".csv");

   print $csv_output;

   exit;  

mysql_close();

       }

 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux