'我的分页代码开始
if (page-1) mod PageNum = 0 then
p = (page-1) /PageNum
else
p = (((page-1)-(page-1) mod PageNum)/PageNum)
end if
if rst.RecordCount mod PageSize = 0 then
n = rst.RecordCount/PageSize
else
n = (rst.RecordCount-rst.RecordCount mod PageSize)/PageSize+1
end if
strHtml=strHtml & "总记录数:<b>" & rst.RecordCount & "</b> 分页:"
if page = 1 then
strHtml=strHtml & "<font face=webdings color=red>9</font>"
else
strHtml=strHtml & "<a title=首页 href="&thisPageName&"?page=1><font face=webdings>9</font></a>"
end if
if p*PageNum > 0 then
strHtml=strHtml & "<a href="&thisPageName&"?page="&p*PageNum&" title=""上"&PageNum&"页""><font face=webdings>7</font></a>"
end if
'strHtml=strHtml & "<b>"
for i=p*PageNum+1 To p*PageNum+PageNum
if i=page then
strHtml=strHtml & " <font color=red>"&i&"</font>"
else
strHtml=strHtml & " <a href="&thisPageName&"?page="&i&" title=""第"&i&"页"">"&i&"</a>"
'strHtml=strHtml & " <a href=""#"" onclick=pageopen("&i&")>"&i&"</a>"
end if
if i=n then Exit For
next
'response.write "page="&page&"<br>"
'response.write "rst.RecordCount="&rst.RecordCount&"<br>"
'response.write "PageSize="&PageSize&"<br>"
'response.write "p="&p&"<br>"
'response.write "n="&n&"<br>"
'response.write "i="&i&"<br>"
'strHtml=strHtml & "</b>"
strHtml=strHtml & " "
if i<n then
strHtml=strHtml & "<a href="&thisPageName&"?page="&i&" title=""下"&PageNum&"页""><font face=webdings>8</font></a>"
end if
if page=n then
strHtml=strHtml & "<Font face=webdings color=red>:</font>"
else
strHtml=strHtml & "<a href="&thisPageName&"?page="&n&" title=""尾页""><font face=webdings>:</font></a>"
end if
'我的分页代码结束
Function GetPageList(curpage,rscount,pagesize,pagelistnum,otherpr)
'当前页curpage
'总页数rscount
'分页记录pagesize
'分页显示数pagelistnum
'其它参数otherpr,没有可以留空串
'声明函数
dim pgcount,firstpage,endpage,lastpage,firststr,endstr,pagelist,pgcount1,addpage
'获取总页数
if rscount = 0 or rscount < pagesize then
pgcount = 1
lastpage = 0
else
pgcount=int(rscount / pagesize)
lastpage=rscount mod pagesize
end if
if lastpage>0 then
pgcount=pgcount+1
end if
if otherpr <> empty then
otherpr = "&" & otherpr
end if
'判断页数是否超出
if clng(curpage)>clng(pgcount) or curpage=empty then
curpage=1
end if
'计算第一页
if len(curpage)>1 then
if clng(curpage mod pagelistnum)=0 then
firstpage=clng(left(curpage,len(curpage)-1))*pagelistnum-pagelistnum+1
else
firstpage=clng(left(curpage,len(curpage)-1))*pagelistnum+1
end if
else
firstpage=1
end if
'计算最后页
endpage=firstpage+pagelistnum-1
if clng(endpage)>clng(pgcount) then
endpage=pgcount
end if
'计算前一个pagelistnum
if clng(curpage)>clng(pagelistnum) then
firststr="[<a href='?page_no="&curpage-pagelistnum&otherpr&"'><<</a>] "
else
firststr="[<<] "
end if
'计算前一页
if clng(curpage)>1 and clng(pgcount)>1 then
firststr=firststr & "[<a href='?page_no="&curpage-1&otherpr&"'><</a>] "
else
firststr=firststr & "[<] "
end if
'计算后一页
if clng(curpage)<clng(pgcount) and clng(pgcount)>1 then
endstr="[<a href='?page_no="&curpage+1&otherpr&"'>></a>] "
else
endstr="[>] "
end if
'计算后一个pagelistnum
if clng(pgcount)-clng(endpage)>0 then
if clng(curpage)-clng(pgcount)>clng(pagelistnum) then
addpage=pagelistnum
else
addpage=clng(pgcount)-clng(endpage)
end if
endstr=endstr &"[<a href='?page_no="&curpage+addpage&otherpr&"'>>></a>]"
else
endstr=endstr&"[>>]"
end if
'获得循环页数
for i=firstpage to endpage
if clng(i)=clng(curpage) then
pagelist=pagelist&"[<font color=red><b>"&i&"</b></font>] "
else
pagelist=pagelist & "[<a href='?page_no="&i&otherpr&"'>"&i&"</a>] "
end if
next
GetPageList=""&rscount&"条记录,每页"&pagesize&"条,分页"&curpage&"/"&pgcount&"]:" & firststr & pagelist & endstr
End Function
偶自己的烂分页过程
三个参数分别是当前页,总页数,连接地址
MyCurrpage:User selected page, MyTotalPage:System MAX page, URL:Other params needed, such as "index.asp?action=input&something=other"
sub page(MyCurrpage,MyTotalPage,URL)
if not isnumeric(MyCurrpage) or not isnumeric(MyTotalPage) then exit sub
dim i,right,left
if MyTotalPage > 10 then
if MyCurrPage <=2 then
right = 10
left = 1
else
if MyCurrPage < MyTotalPage - 7 then
right = MyCurrPage + 7
left = MyCurrPage - 2
else
right = MyTotalPage
left = MyTotalPage - 9
end if
end if
else
right = MyTotalPage
left = 1
end if
if MyTotalPage > 10 then response.write "<a class=nav href="&URL&"&page=1>«</a>"
for i = left to right
if i <> cint(MyCurrPage) then
response.write " <a href="&URL&"&page="&i&">["& i &"]</a>"
else
response.write " <b>["& i &"]</b>"
end if
next
if MyTotalPage > 10 then response.write " ... <a href="&URL&"&page="&MyTotalPage&">["& MyTotalPage &"]</a><a class=nav href="&URL&"&page="&MyTotalPage&">»</a>"
end sub