Program | pagination | problem <%
Set Rs=createobject ("Adodb.recordset")
Rs.Open "SELECT * from table", conn,1,1
If Rs.eof Then
Response.Write "No records!"
Else
If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
rs.pagesize=10
Totalput=rs.recordcount
Totalpage=rs.pagecount
Maxperpage=rs.pagesize
If Currentpage<1 Then
Currentpage=1
End If
If Currentpage>totalpage Then
Currentpage=totalpage
End If
If Currentpage=1 Then
Showhead ' pagination results display head, such as a total of several pages of records and stuff.
Showcontent ' Show this page recordset
Showfoot ' distribution results show tail, such as links to other pages
Else
if (currentPage-1) *maxperpage<totalput Then
Rs.move (currentPage-1) *maxperpage
Showhead
Showcontent
Showfoot
Else
End If
End If
End If
Sub Showcontent
Dim i,j
I=1
Do as not (rs.eof or ERR)
%>
' Enter the single record display mode here
<%
If I>=maxperpage then Exit Do
I=i+1
Rs.movenext
Loop
End Sub
Link code to other pages:
1, link to the previous page, the next page, home and last
<%
If currentpage <> 1 Then
Response.Write "<a href=show.asp>[first page]</a>"
Response.Write "<a href=show.asp?" Page= "& (currentPage-1) &" >[prev]</a> "
End If
If currentpage <> Rs. PageCount Then
Response.Write "<a href=show.asp?" Page= "& (currentpage+1) &" >[next]</a> "
Response.Write "<a href=show.asp?" Page= "& Totalpage &" >[last page]</a> "
End If
%>
2, jump to any one of the pages
<form action= "show.asp" method= "get" align= "right" style= "margin-top:0px"; margin-bottom:0px ">
<%for I=1 to N
Response.Write "<option value=" & I
If Currentpage=i Then
Response.Write "Selected"
End If
Response.Write ">" & I & "</option>"
Next
Response.Write "</select>"
Response.Write "<input class=buttonface type= ' submit ' value= ' Go ' style= ' font-family: Song body; Font-size:8pt;height:19 ' > '
%>
3, link to the beginning of the current page after 10 pages
<%
For J=currentpage+1 to Currentpage+10
If J>totalpage then Exit do%>
<a href= "Show.asp?page=<%=j%>" ><%=j%></a>
<%
Next
%>