本文共 1337 字,大约阅读时间需要 4 分钟。
我试图用阿拉伯语对 alphabetical order 中的结果进行排序,但出于某种原因 not sorting correctly ..
$ d1 = mysqli_query($ connector,“SELECT * FROM article where type ='1'ORDER BY name ASC”); while($ a1 = mysqli_fetch_array($ d1)){echo“$ a1 [name]”; }
这应该显示结果A-z排序或阿拉伯语:
احمد
اياد
بسام
تامر
جعفر
حسين
خضر
ياسمين
但显示结果ilke:
تامر
جعفر
حسين
ياسمين
احمد
اياد
بسام
خضر
注意:我使用的是utf-8编码, utf8_general_ci
Full Mysql Code ::
CREATE TABLE IF NOT EXISTS `article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(150) NOT NULL,
`type` int(11) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
INSERT INTO `article` (`id`, `name`, `type`, `content`) VALUES
(1, '222', '', 'tst'),
(2, '111', '', '121'),
(3, 'جعفر', '', 'cont..'),
(4, 'احمد', '', 'cont..'),
(5, 'تامر', '', 'cont..'),
(6, 'اياد', '', 'cont..'),
(7, 'يحيى', '', 'cont..'),
(8, 'بسام', '', 'cont..'),
(9, 'بشير', '', 'cont..');
PHP Code :
$host = 'localhost';
$user = 'root';
$pass = '123';
$dbname = 'article_test';
$connector = mysqli_connect($host, $user, $pass, $dbname) or die("Problem occured while connecting to Mysql Server..");
$d1 = mysqli_query($connector,"SELECT * FROM `article` where `type`='1' ORDER BY `name` ASC");
while($a1 = mysqli_fetch_array($d1)){
echo"$a1[name]
";
}
结果应该是:
111
222
احمد
اياد
بسام
بشير
تامر
جعفر
يحيى
有人有线索吗 ?
转载地址:http://mhyvx.baihongyu.com/