<%
dim rsd,sql
sql="select * from product "
set rsd=server.CreateObject("adodb.recordset")
rsd.open sql,conn,1,1
if rsd.eof and rsd.bof then
response.write "
-------等待中...。"
set rsd=nothing
Response.End
end if
%>
<%
dim currentpage,page_count,Pcount
dim totalrec,endpage
if request("page")="" then
currentPage=1
else
currentPage=cint(request("page"))
end if
perpage=10
rsd.PageSize = perpage
rsd.AbsolutePage=currentpage
page_count=0
totalrec=rsd.recordcount
while (not rsd.eof) and (not page_count = rsd.PageSize)
%>
')"><%=rsd("name")%>
<%=rsd("price1")%> / 浏览<%=rsd("price2")%>次
<%
page_count = page_count + 1
rsd.movenext
wend
call pages()
rsd.close
set rsd=nothing
sub pages()
dim ii,p,n
if totalrec mod perpage=0 then
n= totalrec \ perpage
else
n= totalrec \ perpage+1
end if
if currentpage-1 mod 10=0 then
p=(currentpage-1) \ 10
else
p=(currentpage-1) \ 10
end if
response.write ""
end sub
%>
教你个方法,
假设当前是第五十页,而你总共只想显示11号页面链接:
先检查当前页,再检查当前页减去五是否小于一,再检查当前页加上五是否大于最大页数。如果都满足,就直接显示四十五至五十五页
如果小于一,则显示一到十页;
如果大于最大页,则显示最大页减十至最大页
搞定咯
^_^
好了,测试下
lCur '当前页面号
lPgCT=rs.PageCount '页面总数
lDispNum =10 '页面显示中每页显示的页码连接的数量
strUrl=""
lPre=(lCur \ lDispNum-1) * lDispNum
lNext=(lCur \ lDispNum+1) * lDsipNum
if lPre>0 then
strUrl="前" & CStr(lDispNum) & "页" & vbCrLf
end if
for lLpV=1 to lDispNum
if lPre+lDispNum+lLpV<> lCur then
strUrl=strUrl & "" & CStr(lPre+lDispNum+lLpV) & "" & vbCrLf
else
strUrl=strUrl & CStr(lPre+lDispNum+lLpV) & vbCrLf
end if
Next
if lNext
end if
response.write strUrl 'strUrl就是页面显示的连接串
帮你定制了一个,不知是否满意
<%
TotalPage=100 '总页数
CurrentPage=Trim(Request.QueryString("page")) '当前页
searchStr=Trim(Request.QueryString("search")) '搜索字串
Pages = Array(1,TotalPage)
If not isNumeric(CurrentPage) or isEmpty(CurrentPage) then '第一次进入页面时,默认当前页为1
CurrentPage=1
end if
call SetPage(CurrentPage,TotalPage)
Response.Write("
http://mis-algoritmos.com/2007/03/16/some-styles-for-your-pagination/
24款实用的翻页页码CSS代码