分页分页!!

不足之处请大家指正!:)
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&"条&nbsp;")
response.Write("每页"&rs.pagesize&"条&nbsp;")            
response.Write("第"&page&"/"&rs.pagecount&"页&nbsp;")
if page>1 and page<=rs.pagecount then response.Write("<a href="&strurl&"&page="&page-1&" class=l9>上一页</a>&nbsp;")
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("&nbsp;转到第<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
posted @ 2005-10-13 12:34  QDuck  阅读(518)  评论(0编辑  收藏  举报