自己常用的分页程序
作者:cmscn 日期:2008-08-13
dim rs,sql,key,strsql,page,i,x
key=request("key") '搜索关键字
strsql="?key="&key
page=cint(request("page"))
if page="" or page<=0 or isnumeric(page)=false then page=1
set rs=.....
sql="..... where .. like'%"%key&"%' or ... like'%"&key&"%'...."
rs.open sql......
if not rs.eof then
rs.movefirst
.....
i=0
do while not rs.eof and i<rs.pagesize
i=i+1
.........
.......
.....
..
rs.movenext
loop
else
page=0
end if
response.Write("共计"&rs.recordcount&"条 ")
response.Write("每页"&rs.pagesize&"条 ")
response.Write("第"&page&"/"&rs.pagecount&"页 ")
if page>1 and page<=rs.pagecount then response.Write("<a href="&strurl&"&page="&page-1&" class=l9>上一页</a> ")
if page<rs.pagecount and rs.pagecount>1 then response.Write("<a href="&strurl&"&page="&page+1&" class=l9>下一页</a>")
if rs.pagecount>1 then
response.Write(" 转到第<select onchange='javascript:location.href=this.options[selectedIndex].value'>")
for x=1 to rs.pagecount
if cint(page)=x then
response.Write("<option value="&strurl&"&page="&x&" selected>"&x&"</option>")
else
response.Write("<option value="&strurl&"&page="&x&">"&x&"</option>")
end if
next
response.Write("</select>页")
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
评论: 0 | 引用: 0 | 查看次数: 392
发表评论