其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
[CODE]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="CONDB.inc"-->
<!--引用数据库连接文件-->
<!--#include file="Cls\WebSiteSetInf.asp"-->
<%
'声明数据库记录集对象
Dim rsano
Dim oWebI
'创建数据库记录集对象
Set rsano=Server.CreateObject("ADODB.Recordset")
'设定数据库记录集游标类型
rsano.cursortype=3
'打开记录集对象
rsano.Open "select * From ANOUCE ORDER BY AnnounceTheDate DESC",con
'设定每页显示记录数
rsano.pagesize=25
'得到请求的页号
page=clng(request("page"))
IF request("page")<>"" then
page=clng(request("page"))
Else
page=1
End IF
IF page<1 Then page=1
If page>rsano.pagecount Then page=rsano.pagecount
rsano.absolutepage=page
'网页样式初始化代码
Dim PageStyleT
Set oWebI=New WebSetInf
Set PageStyleT=New PageStyle
Call QueryStyle("网站公告页面",PageStyleT)
%>
<title><%=oWebI.WebName%>-网站公告页面</title>
<!--去除超连接下划线样式表和字体大小设定代码-->
<style type="text/css">
<!--
<%=PageStyleT.StyleString%>
-->
</style>
<STYLE type=text/css>
A {
TEXT-TRANSFORM: none; TEXT-DECORATION: none
}
UNKNOWN {
TEXT-DECORATION: underline
}
.style22 {font-size: 12px}
.style16 {font-size: 14px}
BODY {
background-color: <%=PageStyleT.BackGround%>;
}
</STYLE>
</head>
<BODY>
<table width="294" height="46" border="0" cellspacing="0">
<tr>
<td width="338"><div align="center" class="style22">公告标题</div></td>
<td width="95"><div align="center" class="style22">发布日期</div></td>
</tr>
<%
'定义循环变量
dim iPage
For iPage=1 to rsano.Pagesize
'recno=(page-1)*rsano.pagesize+ipage记录编号计算公式
Response.Write("<tr>")
Response.write("<td><span class=style16><a href=announceview.asp?anbh="&rsano.Fields(0).Value&" target=_self>"&rsano.Fields(1).Value&"</a></span></td>")
Response.Write("<td><span class=style22>"&FormatDateTime(rsano.Fields(4).Value,2)&"</span></td>")
Response.Write("</tr>")
rsano.MoveNext
IF rsano.EOF Then
Exit For
End If
Next
%>
</table>
<table width="293" border="0">
<tr>
<%
'翻页控制代码
IF page<>1 Then
Response.Write("<td><span class=style22><a href=announce.asp?page=1>第一页</a></span></td>")
Response.Write("<td><span class=style22><a href=announce.asp?page="&(page-1)&">上一页</a></span></td>")
Else
Response.Write("<td><span class=style22>第一页</span></td>")
Response.Write("<td><span class=style22>上一页</span></td>")
End IF
IF page<>rsano.pagecount then
Response.Write("<td><span class=style22><a href=announce.asp?page=" & (page+1) & ">下一页</a></span></td>")
Response.Write("<td><span class=style22><a href=announce.asp?page=" & rsano.pagecount & ">最后一页</a></span></td>")
Else
Response.Write("<td><span class=style22>下一页</span></td>")
Response.Write("<td><span class=style22>最后一页</span></td>")
End IF
%>
<td><span class=style22>共<%=rsano.pagecount%>页</span></td>
<td><span class=style22>当前第<%=page%>页</span></td>
</tr>
</table>
<%
'网页对象析构代码
Set PageStyleT=Nothing
rsano.Close
con.Close
Set rsano=Nothing
Set con=Nothing
Set oWebI=Nothing
%>
</body>
</html>[/CODE]
其实ADODB.RecordSet里内置了分页算法。