1. Paging Effect: Home first 10 1 2 3 4 5 6 7 8 9 10 later 10 last
<%
Dim Ipagecount,i,pagestart,pageend
Ipagecount = 30 ' Suppose there are 30 pages
If Request ("display") = "" Then
Curpage=1
Else
Curpage=cint (Request ("display")
End If
' Pages starting from Pagestart
Pagestart = ((curpage-1)/10) *10+1
' Pages from Pageend end
Pageend = Pagestart + 9
' If you exceed the total number of records, Pageend equals the total number of records
If Pageend > ipagecount Then pageend = Ipagecount
Response.Write ("First" & Curpage & "/" & Ipagecount & "page")
If Pagestart > 1 Then Response.Write ("<a href=test.asp?display=" & pageStart-10 & "><<</a>& amp;nbsp; ")
For i = Pagestart to Pageend
Response.Write ("<a href="? display= "& I &" ' > First "& I &" page </a> ")
Next
If Pageend < Ipagecount Then Response.Write ("<a href=test.asp?display=" & Pagestart + ten & ">>>< /a> ")
%>
2. Pagination Effect: A total of X article first prev Next last
'***********************************************
' Procedure name: ShowPage
' Function: Show "previous page next page" and other information
' parameter: sfilename----link Address
' Total number of totalnumber----
' Maxperpage----number per page
' Showtotal----Show total quantity
' Showallpages---whether to use the Drop-down list to display all the pages for jump. Some pages are not available, otherwise a JS error will appear.
' Strunit----count unit
'***********************************************
Sub ShowPage (Sfilename,totalnumber,maxperpage,showtotal,showallpages,strunit)
Dim n, I,strtemp,strurl
If Totalnumber mod maxperpage=0 then
n= Totalnumber/maxperpage
Else
n= totalnumber/maxperpage+1
End If
strtemp= "<table align= ' center ' ><form name= ' showpages ' method= ' Post ' action= '" & sFileName & "' > <tr><td> "
If Showtotal=true Then
Strtemp=strtemp & "Total <b>" & Totalnumber & "</b>" & Strunit & " "
End If
Strurl=joinchar (sFileName)
If Currentpage<2 Then
Strtemp=strtemp & "First prev "
Else
Strtemp=strtemp & "<a href= '" & strURL & "Page=1 ' > Home </a> "
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & (CurrentPage-1) & "' > Previous </a> "
End If
' Response.Write (strtemp)
If N-currentpage<1 Then
Strtemp=strtemp & "Next Page last"
Else
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & (currentpage+1) & "' > Next page </a> "
Strtemp=strtemp & "<a href= '" & strURL & "Page=" & N & "' > Last </a>"
End If
' Response.Write (strtemp)
Strtemp=strtemp & " page: <strong><font color=red>" & currentpage & "</font>/" & N & "</strong> page"
Strtemp=strtemp & " <b>" & Maxperpage & "</b>" & strunit & "/page"
If Showallpages=true Then
Strtemp=strtemp & " goto: <select name= ' page ' size= ' 1 ' onchange= ' javascript:submit () ' > '
For i = 1 to n
Strtemp=strtemp & "<option value= '" & I & "'"
If CInt (currentpage) =cint (i) then Strtemp=strtemp & "selected"
Strtemp=strtemp & "> First" & I & "Page </option>"
Next
Strtemp=strtemp & "</select>"
End If
Strtemp=strtemp & "</td></tr></form></table>"
Response.Write strtemp
End Sub
'***********************************************
' Function name: Joinchar
' Function: Add to address? Or &
' Parameters: strURL----URL
' Return value: Added? or & 's Web site
'***********************************************
function Joinchar (strURL)
If Strurl= "" Then
Joinchar= ""
Exit function
End If
If InStr (strURL, "?") <len (strURL) Then
If InStr (strURL, "?") >1 Then
If InStr (strURL, "&") <len (strURL) Then
Joinchar=strurl & "&"
Else
Joinchar=strurl
End If
Else
Joinchar=strurl & "?"
End If
Else
Joinchar=strurl
End If
End Function
Call can be called as follows:
ShowPage Strfilename,totalput,maxperpage,true,false, "article"
strFileName: Connection File
Totalput: Total Records
Maxperpage: Display quantity per page
3. A more flexible way, you can set the paging display effect
' Paging list function
' URL Jump Address
' Querry? ' after the argument
' Separator Separator
' ListType Paging type
' Type: 0 "First Page | Previous Page | Next Page | Last Page "
' Type: 1 ' 1 | 2 | 3 | 4 | ..........| Next Page "
' Type: 2 ' first page | First 10 pages | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | After 10 pages | Last Page "
' Listlink the style used by the link
Sub PageList (Listtype,url,querry,separator,listlink)
If separator= "" Then separator= "|"
If listtype= "" then listtype= "0"
Select Case ListType
Case "0"
Response.Write "¤tpage&"/"&n&" page
Response.Write "Total" &totalrec& "message "
If CurrentPage <= 1 Then
Response.Write "first Page " &Separator& " "
Response.Write "Previous Page " &Separator& " "
Else
Response.Write "<a href=" "&url&"?page=1& "&querry&" "class=" "" &ListLink& "" > First page </a> " &Separator& " "
Response.Write "<a href=" "&url&" "Page=" ¤tpage-1& "&" &querry& "" "Class=" "" &ListLink& "" > previous page </a> " &Separator& " "
End If
If currentpage = n Then
Response.Write "Next Page " &Separator& " "
Response.Write "last Page "
Else
Response.Write "<a href=" "&url&" "Page=" ¤tpage+1& "&" &querry& "" "Class=" "" &ListLink& "" > next page </a> " &Separator& " "
Response.Write "<a href=" "&url&" page= "&n&" & "&querry&" "" class= "" "&listlink & "" > Last page </a> "
End If
Case "1"
If CurrentPage < n Then
Response.Write "<a href=" "&url&" "Page=" ¤tpage+1& "&" &querry& "" "Class=" "" &ListLink& "" > next page </a> "
Else
Response.Write "Next Page "
End If
For I=1 to N
If CStr (i) =cstr (currentpage) Then
Response.Write "<b>" &i& "</b>" & " " &Separator& " "
Else
Response.Write "<a href=" "&url&" page= "&i&" & "&querry&" "" class= "" "&listlink & "" > "&i&" </a> " &Separator& " "
End If
Next
Case "2"
Pagemercout=10 ' Maximum number of pages that can be flipped each time
' Get the maximum number of records
If n mod pagemercout=0 then
Maxpagefiled=n/pagemercout
Else
Maxpagefiled=n/pagemercout+1
End If
' Determine the page number of the current page
If CurrentPage mod pagemercout =0 Then
Currpagefiled=currentpage/pagemercout
Else
Currpagefiled=currentpage/pagemercout+1
End If
' Get the maximum and minimum page numbers for the current page segment
Maxpageno=currpagefiled*pagemercout
minpageno= (CurrPageFiled-1) *pagemercout+1
' Output ' first page | First 10 pages | "
If Currentpage<=1 Then
Response.Write "first Page " &Separator& " "
Else
Response.Write "<a href=" "&url&"?page=1& "&querry&" "class=" "" &ListLink& "" > First page </a> " &Separator& " "
End If
If Currpagefiled<=1 Then
Response.Write "Top 10 pages " &Separator& " "
Else
Response.Write "<a href=" "&url&" "Page=" &MinPageNo-PageMerCout& "&" &querry& "" " Class= "" "&ListLink&" "" > First 10 pages </a> " &Separator& " "
End If
' Output current page segment
For I=minpageno to Maxpageno
If I<=n Then
If CStr (i) =cstr (currentpage) Then
Response.Write "<b>" &i& "</b>" & " " &Separator& " "
Else
Response.Write "<a href=" "&url&" page= "&i&" & "&querry&" "" > "&i&" </a > " &Separator& " "
End If
End If
Next
' Output ' after 10 pages | Last Page "
If Currpagefiled>=maxpagefiled Then
Response.Write "After 10 pages " &Separator& " "
Else
Response.Write "<a href=" "&url&" page= "&MaxPageNo+1&" & "&querry&" "" Class= "" "& listlink& "" "> 10 page </a> " &Separator& " "
End If
If Currentpage>=n Then
Response.Write "last Page "
Else
Response.Write "<a href=" "&url&" page= "&n&" & "&querry&" "" class= "" "&listlink & "" > Last page </a> "
End If
End Select
End Sub
4. A relatively simple
On Error Resume Next
' Paging program
function fy (scount,pgsize,pg,url)
' Scount Total Records
' Pgsize per surface record number
' PG Current Page
' URL to the address, after running this function will be followed by the "&page= page number"
Dim pgcount,i,j,mh,k
MH=CHR (34) ' Sorry, it's double quotes.
' CInt () will be rounded, so I have to add a K
k= (scount+pgsize-1)/pgsize
Pgcount=cint ((scount+pgsize-1)/pgsize)
If Pgcount>k then pgcount=pgcount-1
Response.Write "<a href=" +mh+url+ "&page=1" +mh+ ">[first page]</a> "
If CInt (PG) >cint (1) Then
Response.Write "<a href=" +mh+url+ "&page=" +cstr (pg-1) +mh+ ">[previous page]</a> "
End If
If CInt (PG) >5 then
I=cint (PG)-5
Else
I=1
End If
If CInt (pgcount) <cint (pg+5) Then
J=pgcount
Else
J=pg+5
End If
While CInt (i) <=cint (j)
If CInt (i) =cint (PG) Then
Response.Write CStr (i) + " "
Else
Response.Write "<a href=" +mh+url+ "&page=" +cstr (i) +mh+ ">" +cstr (i) + "</a> "
End If
I=i+1
Wend
If CInt (Pgcount) >cint (PG) Then
Response.Write "<a href=" +mh+url+ "&page=" +cstr (pg+1) +mh+ ">[next page]</a> "
End If
Response.Write "<a href=" +mh+cstr (URL) + "&page=" +cstr (pgcount) +mh+ ">[last page]</a> "
End Function