我要将数据从SQL导出到Excel文件(csv)。现在,我可以将数据从SQL导出到Excel但它不懂日语(它在我从SQL导出的Excel文件中成为?????)。
以下是SQL中的数据
ccode country
AL Albania
AD Andorra
AO Angola
BR Brazil
JP 東京
以下是导出后的Excel文件(csv)中的数据
ccode country
AL Albania
AD Andorra
AO Angola
BR Brazil
JP ????
以下是我导出数据的编码
<?php
//connection
include('dbconfig.php');
//create query to select as data from your table
$contents="ccode,country\n";
//Mysql query to get records from datanbase
$user_query = mysql_query('SELECT * FROM countries');
//While loop to fetch the records
while($row = mysql_fetch_array($user_query))
{
$contents.=$row['ccode'].",";
$contents.=$row['country']."\n";
}
// remove html and php tags etc.
$contents = strip_tags($contents);
header('Content-type: application/vnd.ms-excel; charset=UTF-8');
header("Content-Disposition: attachment; filename=data".date('d-m-Y').".csv");
print $contents;
?>
任何人都可以帮我解决这个问题吗?
提前感谢。