Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Kenneth Cho on Feb 24, 2009 02:52
open dhtmlx forum
don't display chinese

Dear Sir,

I used the dataprocessor and get the data from the database show in the grid,
but it can' t work. Please help,
the following code is get.php in use.
thank you.

<?php
//set content type and xml tag
//header("Content-type:text/xml");
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

//define variables from incoming values
if(isset($_GET["posStart"]))
$posStart = $_GET['posStart'];
else
$posStart = 0;
if(isset($_GET["count"]))
$count = $_GET['count'];
else
$count = 150;

//connect to database
$link = mysql_pconnect("localhost", "root", "abc");
$db = mysql_select_db ("abcd");

//create query to products table
$sql = "SELECT * FROM test";

//if this is the first query - get total number of records in the query result
if($posStart==0){
$sqlCount = "Select count(*) as cnt from ($sql) as tbl";
$resCount = mysql_query ($sqlCount);
$rowCount=mysql_fetch_array($resCount);
$totalCount = $rowCount["cnt"];
}

//add limits to query to get only rows necessary for the output
$sql.= " LIMIT ".$posStart.",".$count;

//query database to retrieve necessary block of data
$res = mysql_query ($sql);

//output data in XML format
print("<rows total_count='".$totalCount."' pos='".$posStart."'>");
while($row=mysql_fetch_array($res)){
print("<row id='".$row['connectionID']."'>");
    print("<cell>");
print($row['dept']); //value for connection ID
print("</cell>");
print("<cell>");
print($row['name']); //value for name
print("</cell>");
print("<cell>");
print($row['eMail']); //value for E-Mail
print("</cell>");
print("<cell>");
print($row['extNum']); //value for ext Num
print("</cell>");
print("<cell>");
print($row['location']); //value location
print("</cell>");

print("</row>");
}
print("</rows>");
?>
Answer posted by Support on Feb 24, 2009 03:26
a) Please be sure that you are using correct encoding ( both html page and data in DB use UTF ) 
b) Your data doesn't contain special chars ( <, >, & ), in other case you need wrap data output as

print("<cell><![CDATA["); 
print($row['dept']); //value for connection ID 
print("]]></cell>");

Also, latest version of dataprocessor supports next command
  dp.enableUTFencoding(true);
You can try to use it , if data from client side saved incorrectly in DB

Answer posted by kenneth cho on Feb 24, 2009 20:39

Dear sir,

I set the charset is utf-8-unicode,

and how to download the new update of dataprocessor used in grid

Answer posted by Support on Feb 25, 2009 05:35
>>And how to download the new update of dataprocessor used in grid.
Please contact us directly at support@dhtmlx.com and provide your reference number. 

>>I set the charset is utf-8-unicode
If same encoding used on all stages - the data must be shown exactly as it stored in DB