Paging
I wrote 2 general ASP paging method for your reference!
<%@ Language=vbscript%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim CurrentPage ' Defines the current page
Dim filename ' filename
Const maxperpage=20 ' number of records displayed per page
Dim Totalnumber ' Total Records
Filename= "Showpages.asp"
totalnumber=200 ' Set record total of 200
If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Showpages Totalnumber,maxperpage,filename
%>
</BODY>
</HTML>
<% ' defines the paging function, with Totalnumber,maxperpage,filename as the entry for the function.
function Showpages (totalnumber,maxperpage,filename)
Dim n
If Totalnumber mod maxperpage=0 then
n= Totalnumber Maxperpage
Else
n= Totalnumber maxperpage+1
End If
Response.Write "<form method=post action=" &filename& ">"
Response.Write "<p align= ' center ' > Record Paging"
If Currentpage<2 Then
Response.Write "<font color= ' 999966 ' > Home prev </font>"
Else
Response.Write "<a href=" &filename& "?page=1> home </a>"
Response.Write "<a href=" &filename& "page=" &CurrentPage-1& "> previous page </a>"
End If
If N-currentpage<1 Then
Response.Write "<font color= ' 999966 ' > Next End </font>"
Else
Response.Write "<a href=" &filename& "page=" & (Currentpage+1)
Response.Write "> Next </a> <a href=" &filename& "? page=" &n& "> Last </a>"
End If
Response.Write "page: <strong><font color=red>" &CurrentPage& "</font>/" &n& "</ Strong> page "
Response.Write "goto: <input type= ' text ' name= ' page ' size=4 maxlength=10
Value= "¤tpage&" > "
Response.Write "<input class=buttonface type= ' Submit ' value= ' Goto ' name= ' Cndok ' ></span></p></ Form> "
End Function
%>
--------------------------------------------------------------------------
<%@ Language=vbscript%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim CurrentPage ' Defines the current page
Dim filename ' filename
Const maxperpage=20 ' number of records displayed per page
Dim Totalnumber ' Total Records
Filename= "Showpages.asp"
totalnumber=200 ' Set record total of 200
If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Showpages Totalnumber,maxperpage,filename
%>
</BODY>
</HTML>
<% ' defines the paging function, with Totalnumber,maxperpage,filename as the entry for the function.
function Showpages ()
Dim n
if (totalnumber mod maxperpage) =0 Then
n= Totalput Maxperpage
Else
n= Totalput Maxperpage + 1
End If
If N=1 Then
Exit Sub
End If
Dim k
Response.Write "<p align= ' left ' >>> pagination"
For K=1 to N
If K=currentpage Then
Response.Write "[<b>" +cstr (k) + "</B>]"
Else
Response.Write "[<b>" + "<a href=" &filename& "page=" +cstr (k) + ">" +cstr (k) + "</a></b> ] "
End If
Next
Response.Write "</p>"
End Function
%>