给我一直在用的一个分页函数给你
'PID 页面中的其它传参连接
'page 要显示的页码
'Vcount 总记录数
'Pnum 每页记录数
'className 超连接样式
public function ThePage(Pid,page,Vcount,Pnum,className)
dim show
page = int(page)
Pcount = abs(int(-abs(Vcount/Pnum)))
if page = "" or page <= 0 then page = 1
if page>Pcount then page=Pcount
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9
If EndPageNum>Pcount then EndPageNum=Pcount
show = show&"<tr><td colspan='10' bgcolor='' align='right' style='padding-right:25px;padding-top:5px;' class='"&className&"'>"
show = show&"共<b>"&Pcount&"</b>页 共有<b>"&Vcount&"</b>记录 第<b>"&page&"</b>页 跳到第 [ "
if StartPageNum>1 then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&StartPageNum-1&"' title='前十页'><font face='webdings'>7</font></a>"
end if
For go=StartPageNum to EndPageNum
if go<>page then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&go&"'>"&go&"</a>"
else
show = show&"<span class='current'><b>"&go&"</b></span>"
end if
show = show&" "
Next
if EndPageNum<Pcount then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&EndPageNum+1&"' title='下十页'><font face='webdings'>8</font></a>"
end if
show = show& "] 页"
if page<>1 then
show = show&" <a class='"&className&"' href='?"&Pid&"page=1'>首页</a> <a class='"&className&"' href='?"&Pid&"page="&page-1&"'>上一页</a>"
end if
if Pcount-page <> 0 then
show = show& " <a class='"&className&"' href='?"&Pid&"page="&page+1&"'>下一页</a> <a class='"&className&"' href='?"&Pid&"page="&Pcount&"'>尾页</a>"
end if
show=show&"</tr></td>"
ThePage = show
end function
=====================使用示例============================
<%
'分页参数设置
sql = "select * from [guestbook] order by orderid,id desc"
page = GQ("page",1)
page = int(page)
Pnum = 15
className = "lwf"
PID = ""
'以下不变
set rs = DB.S(SQL,1)
Vcount = RS.recordcount
if RS.recordcount <> 0 then
RS.absoluteposition=RS.absoluteposition+((abs(page)-1)*Pnum)
end if
'********************************
i = 1
while not RS.eof and i<=Pnum
%>
<tr>
<td width="3%" height="25" align="center"><img src="images/ico1.jpg" width="6" height="6" /></td>
<td align="left" class="other_font5"><%=rs("title")%></td>
</tr>
<tr>
<td class="other_font9"> </td>
<td class="other_font9"><%=rs("contents")%></td>
</tr>
<%
rs.movenext
i = i + 1
wend
rs.close
set rs = nothing
%>
<div class="pagination"><%=WEB.ThePage(Pid,page,Vcount,Pnum,className)%></div>
===================分页样式 ==================================
<style>
div.pagination {
margin: 50px 15px 50px 0 ;
text-align:center;
clear:both;
}
div.pagination a {
border: 1px solid #5a5a5a;
margin-right:3px;
padding:2px 6px;
font-family:"宋体";
background-position:bottom;
text-decoration: none;
color: #fff;
}
div.pagination a:hover, div.meneame a:active {
background-image:none;
background-color:#dd4b2f;
color: #fff;
text-decoration:none;
}
div.pagination span.current {
margin-right:3px;
padding:2px 6px;
background-color:#dd4b2f;
font-weight: bold;
border: 1px solid #5a5a5a;
color: #fff;
}
div.pagination span.disabled {
margin-right:3px;
padding:2px 6px;
border: 1px solid #5a5a5a;
color: #000;
background-color:#fff;
}
</style>
<%
'page为当前页的码
'从当前页减counts到当前页加counts
'百度的为前9页到后9页
dim counts,totalPages
counts=9
totalPages=rs.recordcount
call ShowPages (totalPages,counts)
'以下为显示页码过程
Sub ShowPages(totalPages,counts)
for j=page-counts to page
if j>0 then
if j=page then
response.Write("<b>"&j&"</b> ")'
else
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
end if
next
for j=page+1 to page+counts
if j<totalPages-9 then
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
next
end sub
%>
if j>0 then
if j=page then
response.Write("<b>"&j&"</b> ")'
else
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
end if
next
for j=page+1 to page+counts
if j<rs.pagecount-9 then
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
next
%>