直接按姓名排序就可以了, 类似这样:
SELECT * FROM `temp` ORDER BY `姓名` ASC LIMIT 0, 30刚才我用MYSQL试过, 可以的. 这样可以弄到姓名按拼音排序的列表, 但无法将各个拼音分开.如果你想要做到上面网页的效果, 补加一个字段, 存放姓名的首拼音, 这样才行.

解决方案 »

  1.   

    补加一个字段呀, 存放歌手姓名的首拼音呀.
    姓名   拼音首字母  
    金城武  J 
    王杰   W 
    王力宏  W 
    陈淑桦  C 
    谢霆锋  X 
    艾可   A 
    邓丽君  D 在这样的情况下写SELECT,你应该会了吧?连排序都免掉了。而且歌手并不多,只是第一次加入的时候需要,以后就是一劳永逸。
      

  2.   

    我想可以用LeeMaRS(小菜虎 - 我要DP!) 的方法试一下。
      

  3.   

    用LeeMaRS(小菜虎 - 我要DP!) 的方法可以了,何必那么麻烦呢
      

  4.   

    用手工添加,是可行.现在我只是想知道怎样能自动取得汉字的拼音首字母.
    MySQL中有这样的函数吗?有简单直接点的方法吗?http://bar.baidu.com/mp3/这里也有.
      

  5.   

    我有一段asp程序。你来改改试试吧,应该没有问题的。可惜我现在没有php环境
    要不就帮你改一下了 得到汉字拼音第一个字母的算法。可能用在查询或排序
    <%
    function getpychar(char)
    tmp=65536+asc(char)
    if(tmp>=45217 and tmp<=45252) then getpychar= "A"
    if(tmp>=45253 and tmp<=45760) then getpychar= "B"
    if(tmp>=47761 and tmp<=46317) then getpychar= "C"
    if(tmp>=46318 and tmp<=46825) then getpychar= "D"
    if(tmp>=46826 and tmp<=47009) then getpychar= "E"
    if(tmp>=47010 and tmp<=47296) then getpychar= "F"
    if(tmp>=47297 and tmp<=47613) then getpychar= "G"
    if(tmp>=47614 and tmp<=48118) then getpychar= "H"
    if(tmp>=48119 and tmp<=49061) then getpychar= "J"
    if(tmp>=49062 and tmp<=49323) then getpychar= "K"
    if(tmp>=49324 and tmp<=49895) then getpychar= "L"
    if(tmp>=49896 and tmp<=50370) then getpychar= "M"
    if(tmp>=50371 and tmp<=50613) then getpychar= "N"
    if(tmp>=50614 and tmp<=50621) then getpychar= "O"
    if(tmp>=50622 and tmp<=50905) then getpychar= "P"
    if(tmp>=50906 and tmp<=51386) then getpychar= "Q"
    if(tmp>=51387 and tmp<=51445) then getpychar= "R"
    if(tmp>=51446 and tmp<=52217) then getpychar= "S"
    if(tmp>=52218 and tmp<=52697) then getpychar= "T"
    if(tmp>=52698 and tmp<=52979) then getpychar= "W"
    if(tmp>=52980 and tmp<=53640) then getpychar= "X"
    if(tmp>=53689 and tmp<=54480) then getpychar= "Y"
    if(tmp>=54481 and tmp<=52289) then getpychar= "Z"
    end functionfunction getpy(str)
    for i=1 to len(str)
    getpy=getpy&getpychar(mid(str,i,1))
    next
    end function
    %>
      

  6.   

    汉字中异体体同音字很多,很有必要有一张对照表。
    来源也很简单,找一个全拼输入法的编码库,逆转换一下就行了。
    介绍一下我的做法:
    1、在win9x下运行输入法生成器,在逆转换选项卡下打开全拼输入法文件winpy.mb(在windows\system目录下),将其保存为文本文件winpy.txt。
    2、删除winpy.txt中的数组部分,就可以得到一张包含地方音的汉字和拼音的对照文本了
    3、接下来的事情就因人而异了
      

  7.   

    LeeMaRS
    当你遇到一个给汉字加上注音的项目时,就不会这么说了
      

  8.   

    3m2u(SameToYou)
    没有成功,
    asp函数中的asc是什么??我没有搞清楚.
    <?php
    function getpychar($char) {         $tmp = 65536+asc($char);         if($tmp>=45217 and $tmp<=45252) $getpychar= "A";
             if($tmp>=45253 and $tmp<=45760) $getpychar= "B";
             if($tmp>=47761 and $tmp<=46317) $getpychar= "C";
             if($tmp>=46318 and $tmp<=46825) $getpychar= "D";
             if($tmp>=46826 and $tmp<=47009) $getpychar= "E";
             if($tmp>=47010 and $tmp<=47296) $getpychar= "F";
             if($tmp>=47297 and $tmp<=47613) $getpychar= "G";
             if($tmp>=47614 and $tmp<=48118) $getpychar= "H";
             if($tmp>=48119 and $tmp<=49061) $getpychar= "J";
             if($tmp>=49062 and $tmp<=49323) $getpychar= "K";
             if($tmp>=49324 and $tmp<=49895) $getpychar= "L";
             if($tmp>=49896 and $tmp<=50370) $getpychar= "M";
             if($tmp>=50371 and $tmp<=50613) $getpychar= "N";
             if($tmp>=50614 and $tmp<=50621) $getpychar= "O";
             if($tmp>=50622 and $tmp<=50905) $getpychar= "P";
             if($tmp>=50906 and $tmp<=51386) $getpychar= "Q";
             if($tmp>=51387 and $tmp<=51445) $getpychar= "R";
             if($tmp>=51446 and $tmp<=52217) $getpychar= "S";
             if($tmp>=52218 and $tmp<=52697) $getpychar= "T";
             if($tmp>=52698 and $tmp<=52979) $getpychar= "W";
             if($tmp>=52980 and $tmp<=53640) $getpychar= "X";
             if($tmp>=53689 and $tmp<=54480) $getpychar= "Y";
             if($tmp>=54481 and $tmp<=52289) $getpychar= "Z";         return $getpychar;}function getpy($str) {
             for ($i=1;$i<strlen($str);$i++) {
                  $getpy = $getpy&getpychar(substr($str,$i,1));
             }
             return $getpy;
    }echo getpy("你");?>我刚改的.大家看看错在哪里.
      

  9.   

    asc()是得到它的ascii码
    我不知道php里是什么函数
      

  10.   

    是ord()
    但结果有问题..我在测试了几个字.都是返回了0
      

  11.   

    你试试 echo ord("啊") 结果是什么?
      

  12.   

    麻烦解释一下这个函数的作用.function getpy(str)
    for i=1 to len(str)
    getpy=getpy&getpychar(mid(str,i,1))
    next
    end function我也没有搞清.
      

  13.   

    to xuzuning(唠叨) 刚搞到那个对照表
    里面有很多词组..是不是应该删除掉??麻烦指点一下.我想把它导入数据库中.每个字母,对应 以该字拼单母为首的 一系列汉字.CREATE TABLE chars (
      word char(1) NOT NULL default '',
      chars varchar(255) default NULL,
      UNIQUE KEY word (word),
      KEY word_2 (word),
      KEY chars (chars)
    ) TYPE=MyISAM;其中 word 是保存 字母的. chars 是保存对应的汉字,
    不知道这样是否合理?
      

  14.   

    asp中asc("啊")=-20319
    看起来它们好像不太一样,不过差值应该一样吧
    你的程序改成下面这样看看能不能行,如果不行自己再想想办法
    呵呵,我们这里要没电了,明天来看你还没解决我就配个php来试试<?php
    function getpychar($char) {         $tmp = 65536-20319+176+ord($char);         if($tmp>=45217 and $tmp<=45252) $getpychar= "A";
             if($tmp>=45253 and $tmp<=45760) $getpychar= "B";
             if($tmp>=47761 and $tmp<=46317) $getpychar= "C";
             if($tmp>=46318 and $tmp<=46825) $getpychar= "D";
      

  15.   

    错了,是
             $tmp = 65536-20319+ord($char);
    呵呵,是这样吧?我头有些大了
      

  16.   

    function getpy(str)
    for i=1 to len(str)
    getpy=getpy&getpychar(mid(str,i,1))
    next
    end function这个没有搞清..现在结果显示的还是0我试了这个
    echo getpychar("你");显示的是 B
      

  17.   

    function getpy(str)
    for i=1 to len(str)
    getpy=getpy&getpychar(mid(str,i,1))
    next
    end function
    这个的意思是得到一个中文字串的拼音,即getpy("我爱你")返回WAN
    你可以不用那个函数 直接echo getpychar("你")试一下