程序代码:
<% '创建数据库记录集对象 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 %> <title>网站公告页面</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> <% '网页对象析构代码 rsano.Close con.Close Set rsano=Nothing Set con=Nothing %> </body> </html>