Everyone knows that paging display of record sets can be easily implemented in Dreamwerver, but the generated code is indeed very large, which affects the display speed of the web page, and does not seem to be very clear. So, can the same thing be achieved in a simple way? What about the function? Of course, I can use the following simple code to realize the paging display of the record set. Now I will share it with everyone.
The main codes are as follows:
<%
If rs1.recordcount>0 Then 'If the record set is not empty, process the record rs1.pagesize = 10 'Set the number of records displayed on each page num=rs1.recordcount 'Total number of records pagenum=rs1.pagecount 'Total number of pages page=request(" page") 'Get the original information of the page number' The beginning of processing the original information of the page number!
If page <> "" then
page = cint(page)
if err.number <> 0 then
err.clear
page=1
end if
if page < 1 then
page=1
end if
else
page=1
End if
if page*rs1.pagesize > num and not((page-1)*rs1.pagesize < num)then
page=1
end if
'End of processing page number original information! Set the current page number rs1.absolutepage = page
%>
<!--Judge whether the current page is the last page, and set the repeated display of records based on the judgment-->
<% if page<>pagenum then
lablenum=rs1.pagesize
else
lablenum=num-(page-1)*rs1.pagesize
end if
for i=1 to labelnum
%>
<tr bgcolor="#FFFFFF">
<td height="25"><div align="center"><%=(rs1.Fields.Item("id").Value)%></div></td>
<td><div align="center"><%=(rs1.Fields.Item("name").Value)%></div></td>
<td><div align="center"><%=(rs1.Fields.Item("Address").Value)%></div></td>
<td><div align="center"><%=(rs1.Fields.Item("Category").Value)%></div></td>
<td><div align="center"><%=(rs1.Fields.Item("Last modified").Value)%></div></td>
<td><div align="center"><%=(rs1.Fields.Item("Modifier").Value)%></div></td>
</tr>
<%
rs1.movenext
next
%>
<!--The record display of the current page ends, the following code is the record set paging link code-->
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="35">
<div align="right">
<font color="#333333">
There are <%=num%> links in total|
<a href=linkadmin.asp?page=1>Homepage</a> |
<%if page>1 then%><a href=linkadmin.asp?page=<%=page-1%>><%end if%>Previous page</a> |
<%if page<pagenum then%><a href=linkadmin.asp?page=<%=page+1%>><%end if%>Next page</a> |
<a href=linkadmin.asp?page=<%=pagenum%>>Last page</a> |
Page:<%=page%>/<%=pagenum%>page |
Total <%=pagenum%>pages</font>
</div>
</td>
</tr>
</table>
<!--The record set paging link code ends, and the following code is executed when the record set is empty-->
<%else%>
<tr bgcolor="#FFFFFF">
<td height="25" colspan="6"><div align="center"><% response.Write("No results to display!") %>
</div></td>
</tr>
<%
end if
rs1.Close()
Set rs1 = Nothing
%>
Okay, it’s very simple! Just make a simple modification and you can insert it into the place where the record is displayed on your web page. Try it now!