<%
function getPageCount( pageCount, RecordCount, rcPerPage)
pageCount=RecordCount/rcPerPage
pageCount=int(pageCount)
if (RecordCount mod rcPerPage)>0 then
PageCount=PageCount +1
end if
if pageCount<1 then
pageCount=1
end if
getPageCount=pageCount
end function
function getPage(page,pageCount)
if page="" or not isNumeric(page) then
page=1
else
page=int(page)
end if
if page>pageCount then
page=pageCount
end if
getPage=page
end function
%><%
function pageList()
dim p,i
if page<1 then
page=1
end if
if pagecount<1 then
pagecount=1
end if
'pagecount=2
p=int(page/pageLinkNum)
if page mod pageLinkNum>0 then
p=p+1
end if
p=(p-1)*pageLinkNum+1
'response.write p
'response.end
i=p+(pageLinkNum-1)
if i> pagecount then
i=pagecount
end if
if p>pageLinkNum then
pageList=pageList & "<a href='?page="&p-1&"'>[<<]</a>"
end if
do while p<=i
if p=page then
pageList=pageList & "["&p&"]"
else
pageList=pageList & "<a href='?page="&p&"'>["&p&"]</a>"
end if
p=p+1
loop
p=p-1
if p< pagecount then
pageList=pageList & "<a href='?page="&(p+1)&"'>[>>]</a>"
end if
end function
%>
这个应该能实现
从9seek留言簿里摘的一段,主要是利用一个求余的功能,以前写过一个,找不到了,过两天有空了,重新写一个给你,你去下载一个9seek留言簿吧
<% RCOUNT = CInt(Request.Querystring("RCOUNT")) %>
<% If RCOUNT = "" Then %>
<% RCOUNT = "0" %>
<% End If %>
<%
Page = Request.QueryString("Page")
If IsEmpty(Request.QueryString("Page")) then Page = 1
%>
<%
sqlstmt = "SELECT * from book ORDER BY id DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlstmt, conn, 3, 3
%>
<%
If rs.EOF then
‘没有留言,加入你的代码’
Else
TotalRecords = rs.recordcount
rs.Pagesize = 8
TotalPages = cInt(rs.pagecount)
rs.absolutepage=Page
%>
<%
rs.movenext
Next 'CountRecords
If Page > 1 Then
%>
<%
End If
If NOT rs.EOF then
%>
<center><td><a href="../Donnotebook/index.asp?Page=<%= Page + 1 %>">下一页 </a></td>
<td><a href="../Donnotebook/index.asp?Page=<%= TotalPages %>">最后一页</a> </td></center>
</tr>
</table>