' This sub-page effect support ' pagination, pagination effect: Home prev ... 2 3 4 5 6 7 ... Next last page This paging mode, has the forum style
' ID title content status updatetime
' 1 T1 C1 1 2010-5-26 21:16:06
' 2 T2 C2 1 2010-5-26 21:16:09
' 3 t3 c3 1 2010-5-26 21:16:12
' 4 T4 c4 1 2010-5-26 21:16:15
' 5 T5 c5 1 2010-5-26 21:16:23
db= "Database/db1.mdb"
Path=server.mappath (DB)
Set Conn=server.createobject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &path
Conn. Open ConnStr
Set Rs=server. CreateObject ("Adodb.recordset")
%>
<!--#include file= "conn.asp"-->
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<style>
td{
font-size:12px;
}
</style>
</HEAD>
<BODY>
<table border=1 cellspacing=0 cellpadding=0 width=500>
<TR>
<TD align= "center" >ID</td>
<TD height= "align=" "Center" > title </TD>
<TD align= "center" > Time </TD>
</TR>
<%
' Pagination method for more than 100,000 data
' Author: wangsdong
' Source: 111cn.net
' Original document, reprint please keep this information, thank you
Keyword=request ("keyword")
Page=request ("page")
If page= "" "Or Not IsNumeric (page) then page=1 Else page=cint (page)
page_size=2
Q1= "and Status>0"
If keyword<> "Please enter the keyword" and keyword<> "" Then
q1=q1& "and title like '%" &keyword& "%"
End If
If Page>1 Then
Sql= ' select top ' &page_size& ' id,title,content,updatetime from news where 1=1 and id< (select min (IDs) from (Sele CT Top ' & (page-1) *page_size& ' ID from news where status>0 ' &q1& ' ORDER by id DESC ' as C1) '
Else
Sql= ' select top ' &page_size& ' id,title,content,updatetime from news where 1=1 '
End If
sql=sql&q1& "ORDER BY id DESC"
Set Rs=server. CreateObject ("Adodb.recordset")
Rs.Open sql,conn,1,1
If not rs.eof then
Do as not rs.eof
ID=RS ("id")
Title=rs ("title")
Content=rs ("content")
Updatetime=rs ("UpdateTime")
' The contents of the ************* cycle begin ************************
%>
<TR>
<td><%=id%></td>
<TD height= "><%=title%></TD>"
<TD><%=updatetime%></TD>
</TR>
<%
' ************* the contents of the Loop End ************************
Rs.movenext
Loop
End If
Rs.close
%>
<TR><TD colspan= "3" height= "a" align= "center" >
<%
' Paging start
' Calculate total Pages
Page_count=1
Sql= "SELECT COUNT (*) as T" from News where 1=1 "&q1
Rs.Open sql,conn,1,1
If Rs.eof Then
Else
Recordset_count=rs ("T")
If Recordset_count mod page_size=0 then
Page_count=recordset_countpage_size
Else
Page_count=recordset_countpage_size+1
End If
End If
Rs.close
' Pagination, pagination effect: First prev ... 2 3 4 5 6 7 ... Next Page last page
If Page=1 Then
Response.Write "Home prev "
Else
Response.Write "<a href=" "page=1&keyword=" &keyword& "" > Home </a> <a href= ""? Page= "&page-1&" &keyword= "&keyword&" "> previous page </a> "
End If
If Page>4 Then
S=page-3
Response.Write "..."
Else
S=1
End If
If Page<=page_count-3 Then
E=page+3
Else
E=page_count
End If
For I=s to E
If I=page Then
Response.Write "<font color=" "#FF8000" "><b>" &i& "</b></font> "
Else
Response.Write "<a href=" "page=" &i& "&keyword=" &keyword& "" > "&i&" </a> "
End If
Next
If Page<page_count-3 Then
Response.Write "..."
End If
If Page=cint (Page_count) Then
Response.Write "<span> next page last page </span>"
Else
Response.Write "<span><a href=" "page=" &page+1& "&keyword=" &keyword& "" "> Next page </a > <a href= ""? page= "&page_count&" &keyword= &keyword& "" "> Last page </a>< /SPAN> "
End If
%>
</td></tr>
</TABLE>
</BODY>
</HTML>