Php obtains the first letter (Chinese characters, numbers, and English letters) in batches ). Php obtains the first letter (Chinese characters, numbers, and English letters) in batches $ mysql_server_name127.0.0.1; changes it to your mysql database server $ mysql_username user; change to your mysql database and use php to obtain the first letter (Chinese characters, numbers, and English letters) in batches)
$ Mysql_server_name = '192. 0.0.1 '; // change it to your mysql database server.
$ Mysql_username = 'user'; // change the username of your mysql database.
$ Mysql_password = 'password'; // change the password of your mysql database.
$ Mysql_database = 'database'; // change the name of your mysql database.
Mysql_connect ('2014. 0.0.1 ', $ mysql_username, $ mysql_password) or die ('database not access ');
Mysql_select_db ($ mysql_database );
Mysql_query ("set names 'utf8 '");
$ Equery2 = "select title from Table 1 ";
$ Result2 = mysql_query ($ equery2 );
While ($ row = mysql_fetch_array ($ result2, MYSQL_BOTH ))
{
$ Title = $ row ["title"];
If (ord ($ title)> 128) {// starts with a Chinese character
Echo $ letter = getfirstchar ($ title );
} Else if (ord ($ title)> = 48 and ord ($ title) <= 57) {// start with a number
Echo $ letter = iconv_substr ($ title, 0, 1, 'utf-8 ');
} Else if (ord ($ title)> = 65 and ord ($ title) <= 90) {// starts with an uppercase letter
Echo $ letter = iconv_substr ($ title, 0, 1, 'utf-8 ');
} Else if (ord ($ title)> = 97 and ord ($ title) <= 122) {// start with lowercase English
Echo $ letter = iconv_substr ($ title, 0, 1, 'utf-8 ');
}
}
Function getfirstchar ($ s0 ){
$ S = iconv ("UTF-8", "gb2312", $ s0 );
$ Asc = ord ($ s {0}) * 256 + ord ($ s {1})-65536;
If ($ asc >=- 20319 and $ asc <=-20284) return "";
If ($ asc >=- 20283 and $ asc <=-19776) return "B"; if ($ asc >=- 19775 and $ asc <=-19219) return "C ";
If ($ asc >=- 19218 and $ asc <=-18711) return "D ";
If ($ asc >=- 18710 and $ asc <=-18527) return "E ";
If ($ asc >=- 18526 and $ asc <=-18240) return "F ";
If ($ asc >=- 18239 and $ asc <=-17923) return "G ";
If ($ asc >=- 17922 and $ asc <=-17418) return "H ";
If ($ asc >=- 17417 and $ asc <=-16475) return "J ";
If ($ asc >=- 16474 and $ asc <=-16213) return "K ";
If ($ asc >=- 16212 and $ asc <=-15641) return "L ";
If ($ asc >=- 15640 and $ asc <=-15166) return "M ";
If ($ asc >=- 15165 and $ asc <=-14923) return "N ";
If ($ asc >=- 14922 and $ asc <=-14915) return "O ";
If ($ asc >=- 14914 and $ asc <=- 14631) return "P ";
If ($ asc >=- 14630 and $ asc <=-14150) return "Q ";
If ($ asc >=- 14149 and $ asc <=-14091) return "R ";
If ($ asc >=- 14090 and $ asc <=-13319) return "S ";
If ($ asc >=- 13318 and $ asc <=-12839) return "T ";
If ($ asc >=- 12838 and $ asc <=-12557) return "W ";
If ($ asc >=- 12556 and $ asc <=-11848) return "X ";
If ($ asc >=- 11847 and $ asc <=-11056) return "Y ";
If ($ asc >=- 11055 and $ asc <=- 10247) return "Z ";
Return false;
}
Dimensions (Chinese characters, numbers, and English letters) $ mysql_server_name = '2017. 0.0.1 '; // change it to your mysql database server $ mysql_username = 'user'; // change it to your mysql database...