I get results from mysql database, and I am creating excel file. However, while english characters are displayed corectly, greek characters are displayed as symbols (unreadable).
Here is the code that I have at this time:
//function cleanData(&$str){
// replace fields that _ACCOUNT_DELETE and turn Capital letters into small
//$str=strtolower($str);
//}
// file name for download
$filename = "customers" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
header('Content-Transfer-Encoding: utf-8');
$flag = false;
$query="SELECT * FROM customers";
$result = mysql_query($query);
while(false !== ($row = mysql_fetch_assoc($result))){
if(!$flag){
// display field/column names as first row
echo "Customers
";
$flag = true;
}
//array_walk($row, 'cleanData');
echo implode("\t", array_values($row)) . "
";
}
Database encoding is latin1_swedish_ci
Any help will be deeply appreciated.
execute this query first.
mysql_query( "SET NAMES utf8");
And use htmlentities before echoing them.
echo htmlentities($data);
I dont know about this but you might try
mysql_set_charset('utf8');