<% @language = "VBScript" codepage= "936"%>
<%
' defines a data connection
Option Explicit
On Error Resume Next
Dim Startime,endtime
Startime=timer ()
Dim Db,conn,rs
db = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("./db.mdb")
Set conn = Server.CreateObject ("adodb.connection")
Set rs = Server.CreateObject ("Adodb.recordset")
Conn.Open DB
%>
<%
'**************
' Pager bar function
' Output wzpage value
'**************
Function Pagination (PageCount)
Dim Wzpage,wzpagecount,pagenum,boardid
Boardid = Request.QueryString ("board_id")
If boardid = 0 Then boardid = 1
If Len (Request.QueryString ("page")) <>0 Then
wzpage = CLng (request.querystring ("page"))
Else
wzpage = 1
End If
If wzpage <= 0 Then wzpage = 1
pagenum = (wzpage 10) *10+1
If wzpage mod = 0 Then pagenum = (wzpage 10) *10-9
If wzpage > Then
Response.Write ("<font face=" "Webdings" ">")
Response.Write ("<a href=" "Board_id=" & Boardid & "&page=1" "title=" "Home" ">9</a>")
Response.Write ("<a href=" "Board_id=" & Boardid & "&page=" & Pagenum-1 & "" title= "" Top 10 Pages "" ;7</a> ")
Response.Write ("</font>")
End If
for pagenum = Pagenum to Pagenum + 9
If pagenum = wzpage Then
Response.Write ("<font color=" "#ff0000" ">")
Response.Write ("[" & Pagenum & "]")
Response.Write ("</font>")
Else
Response.Write ("<a href=" "Board_id=" & Boardid & "&page=" & Pagenum & "" " ;")
Response.Write ("[" & Pagenum & "]")
Response.Write ("</a>")
End If
If pagenum >= pagecount Then Exit for
Next
If Wzpage < (PageCount-(PageCount)) Then
Response.Write ("<font face=" "Webdings" ">")
Response.Write ("<a href=" "Board_id=" & Boardid & "&page=" & Pagenum & "" title= "" After 10 page ">8</a>")
Response.Write ("<a href=" "Board_id=" & Boardid & "&page=" & PageCount & "" title= "" Last "" " ;:</a> ")
Response.Write ("</font>")
End If
End Function
%>
<%
Dim rssql,getstring
getstring = CLng (Request.QueryString ("board_id"))
if GetString = 0 Then GetString = 1
'******************************************
' Take the total number of articles and repeat the number of pages per page, prepare pagination
' Wzcount The total number of articles
' Wzrep the number of repeated display bars
' Wzpage paging parameter ID
' Wzpagecount Total pages
'******************************************
Dim wzcount,wzrep,wzpage,wzpagecount,wzpagerep,boardstr
Wzrep = 30
' Rssql = ' select count (id) from ' table1 '
' Rs.Open rssql,conn,0,1,&h0001
Wzcount = Conn.execute ("SELECT count (id) from ' table1 '", 0, 1) (0)
' Rs.close
Wzpagecount = ABS (int (-abs (wzcount/wzrep)))
Wzpage = CLng (request.querystring ("page"))
If Len (wzpage) = 0 or wzpage = 0 Then wzpage = 1
%>
<html>
<head>
<title> pagination Test </title>
<meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 ">
<link rel= "stylesheet" href= "Page.css" type= "Text/css" >
</head>
<body>
<table width= "760" border= "1" cellspacing= "0" cellpadding= "4" align= "center" bordercolordark= "#ffffff" bordercolorlight= "#cccccc" >
<tr align= "center" >
<td width= ">ID</td>
"
<td width= > title </td>
<td width= "*" > Content (Display first 20 words) </td>
<td width= > Time </td>
</tr>
<%
' Take a list of articles
rssql = "Select ID,AAAA,BBBB,CCCC from ' table1 ' ORDER by id DESC"
Rs.Open rssql,conn,1,1,&h0001
' Gets the current page record based on the paging parameter
rs.absoluteposition=rs.absoluteposition+ (ABS (Wzpage)-1) *wzrep)
' Displays the article title list
if rs.eof or Rs.bof then%>
<tr>
<td > No record </td>
</tr>
<% Else
Dim I,bgcolor
for i = 0 to wzrep-1
if Rs.eof then exit for
' While not rs.eof and I <= wzrep
bgcolor= "#FFFFFF"
if I mod 2=0 then bgcolor= "#DFEFFF"
%>
<tr bgcolor= "<%=bgColor%>" >
<td width= "><%=rs" (0)%></td>
<td width= "><%=rs" (1)%></td>
<td width= "*" ><%=left (RS (2),%></td>
<td width= "><%=rs" (3)%></td>
</tr>
<%
Rs.movenext
' i=i+1
' Wend
Next
End If
%>
</table>
<table width= "760" border= "0" cellspacing= "2" cellpadding= "2" align= "Center" >
<tr>
<td align= "left" width= "a" > A total of <font color=red><%= (wzcount%></font>) <font t;<%= wzrep%></font>/page <font color=red><%= wzpagecount%></font> page </td>
<td align= "right" > <%= pagination (wzpagecount)%></td>
</tr>
</table>
<table width= "760" border= "0" align= "center" cellpadding= "2" cellspacing= "2" >
<tr>
<td align= "center" >
<%endtime=timer ()%>
This page execution time: <%=formatnumber ((endtime-startime) *1000,3)%> Ms </td>
</tr>
</table>
</body>
</html>
<%
' Release Resources
Rs.close
Set rs = Nothing
Conn.close
Set conn = Nothing
%>