I'm going to export data from SQL to Excel file (csv). For now, i can exported data from SQL to Excel but it doesn't know Japanese language (it becomes ????? in Excel file that i export from SQL).
Here is data in SQL
ccode country
AL Albania
AD Andorra
AO Angola
BR Brazil
JP 東京
Here is data in Excel file (csv) after i exported
ccode country
AL Albania
AD Andorra
AO Angola
BR Brazil
JP ????
Here is my coding to export data
<?php
//connection
include('dbconfig.php');
//create query to select as data from your table
$contents="ccode,country
";
//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']."
";
}
// 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;
?>
Can anyone help me with this problem?
Thank in advance.