A
Alan
Alex
Amar
Andy
B
Bob
Brad
C
Calvin
Clerk
D
E
我可以使用 ASC 顺序按字母顺序对字段进行排序,但如何将它们放入字母组中。
任何建议都是非常受欢迎的。我正在使用 php。
也许这是一个不好的方法,但它现在可以帮助你。
<?php
$aGroup = array(
"A" => array(),
"B" => array(),
"C" => array(),
"D" => array(),
"E" => array(),
// until "Z"
);
$result = mysql_query("SQL as you want");
while ($row = mysql_fetch_array($result)) {
$letter = strtoupper($row[0][0]); // I supose that the first column is the name
$aGroup[$letter][] = $row;
}
?>