|
This combination DB and CSS script is modeled off of the popular DIGG web site pagination style.
The key component is this line: ps = getPaginationString(page, mycount, 5, 2, "pagination.asp?foo=bar")
Where the numeral "5" is the number of returned responses per "page".
In addition, when changing that variable you will need to make a slight alteration to the database sql statement:
sql = "SELECT * FROM Clients WHERE ID > "&((Cint(page)*5)-5)&" AND ID <= "&Cint(page)*5&";"
By changing all instances of the numeral "5" to the number of returned rows per page you want to use.
Our database table for this example is named "Clients" you would, of course, need to change your DB table and connections in the code.
Download the code here.
One database call creates a record count:
DBConn.Open ConnectStr
sql = "SELECT COUNT(*) AS mycount FROM Clients "
Set RsCOUNT = Server.CreateObject("ADODB.Recordset")
RsCOUNT.Open sql, DBConn, 3, 3
mycount=RsCOUNT("mycount")
While the other grabs the records:
DBConn1.Open ConnectStr
sql = "SELECT * FROM Clients WHERE ID > "&((Cint(page)*5)-5)&" AND ID <= "&Cint(page)*5&";"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql, DBConn1, 3, 3
Do While Not Rs.EOF
 |  |
Client Name |
Join Date |
Mike Mac | 4/30/2005 |
Jane Doe | 5/1/2005 |
Michael Green | 5/15/2005 |
sam Blue | 5/30/2005 |
Joe Blow | 6/15/2005 |
|
|
|