按首字母搜索时怎么实现的?

sayfree 2009-09-20 10:33:17
娱乐网站上的格式都是按照英文字母顺排列的。不知道这个功能是怎么实现的。
怎么实现点A的时候,在数据库里调用首字母是a的歌星?比如:安贞焕 安然 阿塔尔 areft......
效果:http://list.mp3.baidu.com/singer/singers.html?id=1?top7
我想再添加歌星的时候,直接弄个首字母字段,添加上首字母。但是感觉这个法太笨了。
...全文
401 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sayfree 2009-09-20
  • 打赏
  • 举报
回复
谢谢3楼。
是不是掉了一个加号+?

function getpychar(char)
dim tmp
tmp=65536+asc(char)

if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53688) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function

fengqipiaobo 2009-09-20
  • 打赏
  • 举报
回复
友情up!
MR丶CHAN 2009-09-20
  • 打赏
  • 举报
回复
up
in0512 2009-09-20
  • 打赏
  • 举报
回复
根据中文获得首字母,然后就可以进行排列了

function getpychar(char)
dim tmp
tmp=65536 asc(char)

if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53688) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
sy_binbin 2009-09-20
  • 打赏
  • 举报
回复
网上有不少获得汉字首字母的函数!你找来看看!!
liuwei_IT_love 2009-09-20
  • 打赏
  • 举报
回复
用模糊查询试试:str="select * from 表 where name like '"&"%"&ss&"%"&"' order by id desc"
sayfree 2009-09-20
  • 打赏
  • 举报
回复
谢8楼。
在人物表里添加了一个字母字段,按照上面的函数,在提交表单的时候,判断明星的姓名,得出一个字母,直接写入数据库,这样在调用的时候就比较方便了。。。
  • 打赏
  • 举报
回复
这个在论坛问了好几次了吧

最方便的就是在添加的时候加一个字段,这样效率会提升不少,要么你就要全部提取出来再进行排序了
in0512 2009-09-20
  • 打赏
  • 举报
回复
恩,是掉了一个+号

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧