Hi,
I want to download data from mysql to excel using Php. below is my code. it is working fine. But when it comes to arabic text, i am not getting arabic text displayed in excel. it is showing junk characters. In the database i am storing the data in unicode. If i download the data in text format i can see them in arabic but not in excel. How can i solve this issue and get the data downloaded to excel with arabic text.
Thanks in advance
Paraman.
<?php include("dbConnect.php"); ?>
<?php
$rowcount = 0;
$data1 = "select * from forum07";
$result = mysql_query($data1) or die('Error, query failed');
$rowcount=mysql_num_rows($
result);
$fieldcount = mysql_num_fields($result);
$header = "<table> <tr>";
for ($i = 0; $i < $fieldcount; $i++)
{
$header = $header. "<td>".mysql_field_name($r
esult, $i)."</td>";
}
$header = $header."</tr>";
while($row = mysql_fetch_row($result))
{
$line = "<tr>";
foreach($row as $value)
{
if ((!isset($value)) OR ($value == ""))
{
$value = "<td></td>";
}
else
{
//$value = str_replace('"', '""', $value);
$value = '<td>'.$value ."</td>";
}
$line .= $value;
}
$data .= trim($line)."</tr>";
}
// $data = str_replace("\r","", $data);
if ($data =="")
{
$data = "n(0) Records Found!n";
}
header("Content-type:appli
cation/vnd
.ms-excel;
charset=windows-1256");
//header("Content-type: application/octet-stream")
;
header("Content-Dispositio
n: attachment; filename=FORUM07_DATA.xls"
);
header("Pragma: no-cache");
header("Expires: 0");
print $header.$data."</table>"
?>
Start Free Trial