标题: 2006-5-20 ASP ACCESS 按汉字拼音查找与排序, 大结 —— By Stabx
正文:
QUOTE:
作用说明:
本代码实现了数据按汉字拼音查找与排序的功能, 同时解决了上一小结不见"芽文"的小臭虫.
URL 地址栏例子:
*.asp?sortby=letterfirst&order=25
可选择汉字在前,或者英文在前显示, 导航栏如下:
first sort: by letter, by hanzi
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
283
shawl.qiu
13:04 2006-5-20
CODE:
CITE:
啊,八
八,擦
擦,搭
搭,鹅
鹅,发
发,嘎
嘎,哈
哈,机
机,咖
咖,拉
拉,呣
呣,嗯
嗯,哦
哦,怕
怕,七
七,然
然,撒
撒,他
他,挖
挖,西
西,呀
呀,匝
匝,做
IUV
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/conn.asp" -->
<!--#include virtual="include/globalabbr.asp"-->
<!--#include virtual="func/func-glossary.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body><br>
<%'拼音2
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' subject : ASP ACCESS 按汉字拼音查找与排序, 大结 —— By Stabx
'
' writer : Stabx<shawl.qiu@gmail.com>
'
' blog : http://blog.csdn.net/btbtd \ http://btbtd.exblog.jp/
'
' blog/site : Phoenix.GI - P.GI / \ 绿色学院 - Green Institute
'
' date : 2006-5-20
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim py,py1,py2
redim py(25),py1(25),py2(25)
py(0)="啊"
py(1)="八"
py(2)="擦"
py(3)="搭"
py(4)="鹅"
py(5)="发"
py(6)="嘎"
py(7)="哈"
py(8)="I"
py(9)="机"
py(10)="咖"
py(11)="拉"
py(12)="呣"
py(13)="嗯"
py(14)="哦"
py(15)="怕"
py(16)="七"
py(17)="然"
py(18)="撒"
py(19)="他"
py(20)="U"
py(21)="V"
py(22)="挖"
py(23)="西"
py(24)="呀"
py(25)="匝"
py1(0)="八"
py1(1)="擦"
py1(2)="搭"
py1(3)="鹅"
py1(4)="发"
py1(5)="嘎"
py1(6)="哈"
py1(7)="机"
py1(8)="I"
py1(9)="咖"
py1(10)="拉"
py1(11)="呣"
py1(12)="嗯"
py1(13)="哦"
py1(14)="怕"
py1(15)="七"
py1(16)="然"
py1(17)="撒"
py1(18)="他"
py1(19)="挖"
py1(20)="U"
py1(21)="V"
py1(22)="西"
py1(23)="呀"
py1(24)="匝"
py1(25)="做"
py2(0)="A"
py2(1)="B"
py2(2)="C"
py2(3)="D"
py2(4)="E"
py2(5)="F"
py2(6)="G"
py2(7)="H"
py2(8)="I"
py2(9)="J"
py2(10)="K"
py2(11)="L"
py2(12)="M"
py2(13)="N"
py2(14)="O"
py2(15)="P"
py2(16)="Q"
py2(17)="R"
py2(18)="S"
py2(19)="T"
py2(20)="U"
py2(21)="V"
py2(22)="W"
py2(23)="X"
py2(24)="Y"
py2(25)="Z"
%>
<p/>
<%
order_=request("order")
sortby_=request("sortby")
if sortby_<>"" then
if sortby_="letterfirst" then
orderby_="asc"
else
orderby_="desc"
end if
else
sortby_="letterfirst"
orderby_="asc"
end if
if order_<>"" then
if order_<=0 then
order_=0
elseif order_>=25 then
order_=25
end if
else
order_=0
end if
response.write "first sort: <a href=?sortby=letterfirst&order="&order_&">by letter</a>, <a href=?sortby=hanzifirst&order="&order_&">by hanzi</a><p/>"
letters="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
j=0
for each letter in split(letters)
response.write "<a href=?sortby="&sortby_&"&order="&j&">"&letter&"</a> "
j=j+1
next
%>
<p/>
<% '连接数据库
set rs=server.CreateObject("adodb.recordset") '创建 rs 数据查询
rs.open "select * from ctarticle where title between '"&py(order_)&"' and '"&py1(order_)&"' or title like '"&py2(order_)&"%' order by title "&orderby_,MM_conn_string,1
response.write rs.recordcount&"<p/>"
do while not rs.eof
response.write py2(order_)&" "&rs("title")&"<p/>"
rs.movenext
loop
rs.close '关闭 rs 连接
set rs=nothing
%>
</body>
</html>