The first is the creation of recordset. The simple paging code copy code is as follows:
<%
set rs=server.createobject(adodb.recordset)
exce=sql 'sql query statement
rs.open exce,conn,1,1
%>
Then there is the setting of paging properties
<%
rs.PageSize=3 'Set page number
pagecount=rs.PageCount 'Get the total page number
page=int(request(page)) 'Receive page number
if page<=0 then page=1 'Judge
if request(page)= then page=1
rs.AbsolutePage=page 'Set the page number of this page
%>
Finally, the paging display in the body
<%
if rs.bof and rs.eof then
response.write(NULL)
else
for i=1 to rs.PageSize
response.write rs(name)
response.write(<hr>)
rs.movenext
next
end if
%>
<p>
<%if page=1 and not page=pagecount then%>
Home|Previous page
<a href=log1.asp?page=<%=page+1%>>Next page</a>|
<a href=log1.asp?page=<%=pagecount%>>Last page</a>
<%elseif page<>1 and not page=pagcount then%>
<a href=log1.asp?page=1>Homepage</a>|
<a href=log1.asp?page=<%=page-1%>>Previous page</a>|
<a href=log1.asp?page=<%=page+1%>>Next page</a>|
<a href=log1.asp?page=<%=pagecount%>>Last page</a>
<%elseif page=pagecount then%>
<a href=log1.asp?page=1>Homepage</a>|
<a href=log1.asp?page=<%=page-1%>>Previous page</a>|
Next page|
Last page
<%end if%>