使用PHP和MySQL按字母顺序检索阿拉伯语单词

时间:2015-04-08 12:29:05

标签: php mysql arabic

我想按字母顺序查看阿拉伯语名称。

我的表:

enter image description here

代码:

<?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文本在db中显示如下:

enter image description here

1 个答案:

答案 0 :(得分:2)

mysqli_set_charset($con, "utf8");