<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
On Error Resume Next
Dim startime,endtime
Startime=timer ()
' Connect to the database
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 pages "" >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
%>
<title> pagination Test </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= "Page.css" type= "Text/css" >
<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 '"
Rs.Open rssql,conn,1,1,&h0001
' Get current page record according to paging parameter
rs.absoluteposition=rs.absoluteposition+ (ABS (Wzpage)-1) *wzrep)
' Show 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 total <font color=red><%= wzcount%></font> strip <font <%= 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>
<%
' Releasing resources
Rs.close
Set rs = Nothing
Conn.close
Set conn = Nothing
%>