CVS结果显示在一栏中

时间:2019-02-09 12:53:33

标签: php csv export-to-csv

我有此csv导出代码。 导出工作正常,但我唯一的问题是结果只显示在一列中

仅当我尝试将文件转换为UTF-8时,问题才会发生, 还有其他解决方法吗?

    $link = mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB);
$link->set_charset("utf8");
  $sql = "SELECT * FROM weekevents";
  $query = mysqli_query($link,$sql);

    $col = "col1,col2,col3,col4 \n";//Column headers
    foreach ($query as $record){
        $cam = explode(';', $record['cam']);
$col .= $record['weekday'].','.$record['week']
      ;
    }
$filename = date("m-Y");

    $csv_handler = fopen ('C:/xampp/htdocs/rge/main-rtl/uploads/שיבוץ חודש -'.$filename.'.csv','w');
    fwrite ($csv_handler, $col);
    fclose ($csv_handler);

    echo 'Data saved to csvfile.csv';

enter image description here

0 个答案:

没有答案