Export Mysql to ecxel/csv arabic encoding

Hello, I want to export a mysql table to excel files and if not to csv, the problem with excel is it gives me data on one line, so I transformed it to csv and it works, the problem is it does not read arabic data

header( ‘Content-Type: text/csv; charset=utf-8; encoding=UTF-8’ );
header(“Cache-Control: cache, must-revalidate”);
header(“Pragma: public”);
header( ‘Content-Disposition: attachment;filename=export.csv’ );

Help appreciated

Did it work before you changed the output to CSV? You’ll have to show more code for us to help better, but make sure your database connection, table, and columns all use UTF-8 too.

Hello,
Database table fields are uft8, It did not work both as excel and csv

It is opening Fine in Notepad, but not in excell

Thats the complete Code:

<?php
header( ‘Content-Type: text/csv; charset=utf-8; encoding=UTF-8’ );
header(“Cache-Control: cache, must-revalidate”);
header(“Pragma: public”);
header( ‘Content-Disposition: attachment;filename=export.csv’ );
$conn = mysql_connect( ‘localhost’, ‘root’, ‘’ ) or die( mysql_error( ) );
mysql_select_db( ‘labora_donnation’, $conn ) or die( mysql_error( $conn ) );
mysql_query(“SET NAMES ‘utf8’”);
$query = sprintf( ‘SELECT * FROM pr2’ );
$result = mysql_query( $query, $conn ) or die( mysql_error( $conn ) );
$row = mysql_fetch_assoc( $result );
if ( $row )
{
echocsv( array_keys( $row ) );
}
while ( $row )
{
echocsv( $row );
$row = mysql_fetch_assoc( $result );
}

function echocsv( $fields )
{
$separator = ‘’;
foreach ( $fields as $field )
{
if ( preg_match( ‘/\\r|\
|,|"/’, $field ) )
{
$field = ‘"’ . str_replace( ‘"’, ‘“”’, $field ) . ‘"’;
}
echo $separator . $field;
$separator = ‘,’;
}
echo "\r
";
}
?>
when it open the file with
Notepad:
id,name,company,numyear,skill,lang,doc,location,subid,date1,date2,conf,oldnew,fil,selek,shahadat,typx,genderprefer
1,CONT22,aaaaa,6,gfhghgg, Arabic English French ,hgfhgfh,0,0,2011-09-01,2011-09-30,yes,new,إداري,إتصل بنا,
2,hgjjhjh11,gfdgfgfgg12,22,jhjhj, Arabic English French ,doc11,0,0,2011-10-19,2011-10-20,yes,new,إداري,التسجيل للدورة التدريبية,

With Excell

id name company numyear skill lang doc location subid date1 date2 conf oldnew fil selek shahadat typx genderprefer
1 CONT22 aaaaa 6 gfhghgg Arabic English French hgfhgfh 0 0 9/1/2011 9/30/2011 yes new إداري إتصل بنا
2 hgjjhjh11 gfdgfgfgg12 22 jhjhj Arabic English French doc11 0 0 10/19/2011 10/20/2011 yes new إداري التسجيل للدورة التدريبية