0
我有很多存儲在語言的一個龐大的數據庫存儲在utf8_unicode_ci的所有數據和我的數據庫歸類爲utf8_unicode_ci我用特殊的PHP頁面調用SQL數據 這是我的代碼:如何將MySQL數據庫中的特殊字符顯示爲html? 。
<?php
header('Content-Type: text/html; charset=utf-8');
$date=$_POST['date'];//I get this information from ajax request
$server_root = "./";
if(file_exists("{$server_root}include-sql/mysql.class.php"))
{
include_once("{$server_root}include-sql/mysql.class.php");
}
include_once("{$server_root}config.php");//database connection information
$db1;
$db1 = new db_mysql($conf['db_hostname'], $conf['db_username'], $conf['db_password'], $conf['db_name']);
$sql = $db1->query("select * from matches where match_date='$date'");
$i=0;
while($sql_results = $db1->fetch_array($sql))
{
$match[$i]['tournament_id'] = $sql_results['tournament_id'];
$match[$i]['id'] = $sql_results['id'];
$match[$i]['match_id'] = $sql_results['match_id'];
$match[$i]['match_date'] = $sql_results['match_date'];
$match[$i]['match_time'] = $sql_results['match_time'];
$match[$i]['match_status'] = $sql_results['match_status'];
$match[$i]['match_venue'] = $sql_results['match_venue'];
$match[$i]['venue_id'] = $sql_results['venue_id'];
$match[$i]['static_id'] = $sql_results['static_id'];
$match[$i]['match_week'] = $sql_results['match_week'];
$match[$i]['localteam_name'] = $sql_results['localteam_name'];
$match[$i]['localteam_score'] = $sql_results['localteam_score'];
$match[$i]['localteam_ft_score'] = $sql_results['localteam_ft_score'];
$match[$i]['localteam_et_score'] = $sql_results['localteam_et_score'];
$match[$i]['localteam_pen_score'] = $sql_results['localteam_pen_score'];
$match[$i]['localteam_id'] = $sql_results['localteam_id'];
$match[$i]['visitorteam_name'] = $sql_results['visitorteam_name'];
$match[$i]['visitorteam_score'] = $sql_results['visitorteam_score'];
$match[$i]['visitorteam_ft_score'] = $sql_results['visitorteam_ft_score'];
$match[$i]['visitorteam_et_score'] = $sql_results['visitorteam_et_score'];
$match[$i]['visitorteam_pen_score'] = $sql_results['visitorteam_pen_score'];
$match[$i]['visitorteam_id'] = $sql_results['visitorteam_id'];
$match[$i]['halftime_score'] = $sql_results['halftime_score'];
$match[$i]['stage_id'] = $sql_results['stage_id'];
$i++;
}
echo json_encode($match);//return json to my ajax function
?>
問題是在mysql中的所有特殊字符都沒有顯示在瀏覽器中的HTML或顯示空值我想知道有什麼我想念它在這裏?如何顯示我的網頁上的文字
你的json數組是怎樣的? –