使用 PHP 和 MySQL 按字母顺序检索阿拉伯语单词
Retrieve Arabic words alphabetically using PHP and MySQL
我想按字母顺序查看阿拉伯名字。
我的table:
代码:
<?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);
?>
FYI 文本在数据库中显示如下:
尝试
mysqli_set_charset($con, "utf8");
我想按字母顺序查看阿拉伯名字。
我的table:
代码:
<?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);
?>
FYI 文本在数据库中显示如下:
尝试
mysqli_set_charset($con, "utf8");