2
我想按字母順序查看阿拉伯語名稱。使用PHP和MySQL按字母順序檢索阿拉伯語單詞
我的表:
代碼:
<?php
$dbhost="xx";
$dbuser="xxx";
$con = mysqli_connect($dbhost,$dbuser, "");
if (!$con)
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_select_db($con,'xxx');;
$query = "SELECT * FROM `boardteam` ORDER BY fName ASC";
mysqli_query($con,"set character_set_server='utf8'");
mysqli_query($con,"set fName 'utf8'");
$result = mysqli_query($con,$query);
if ($result)
{
while($db_field = mysqli_fetch_assoc($result))
{
$tname ="";
switch ($db_field['titleName'])
{
case "Dr":
$tname = "د.";
break;
case "Ms":
$tname = "السيدة.";
break;
case "Mr":
$tname = "السيد.";
break;
}
$members .= "<li><a href='browseMember.php?id=".$db_field['nationalID']."'>".$tname." ".$db_field['fName']." ".$db_field['sName']." ".$db_field['lName']."</a></li>";
}
}
mysqli_close($con);
?>
僅供參考文本顯示在DB這樣的:
嘗試'mysqli_set_charset($ con,「utf8」);' –
Works很好,現在它正確存儲^^願上帝保佑你,非常感謝 – Learner