ASP自动分页代码

这是一个使用ASP实现的自动分页代码示例,通过ADO Recordset对象进行数据库查询,并设置每页显示记录数,同时提供了上一页、下一页、首页和尾页的导航功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@LANGUAGE="VBSCRIPT"%>
<%dim dsa
If Session("MM_Username")="" Then
response.redirect "index.asp"
end if
%>
<!--#include file="fang.asp" -->
<!--#include file="conn.asp" -->
<HTML>
<HEAD>
<TITLE>恒盛代练系统</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<style type="text/css">
<!--
.unnamed1 {
 border: thin groove #666666;
}
body,td,th {
 font-size: 12px;
}
.STYLE1 {color: #FF0000}
-->
</style>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<!-- ImageReady Slices (未标题-1) -->
<div align="center">
  <table width="778" height="86" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td height="21" colspan="3"><img src="images/5.gif" width="778" height="21"></td>
    </tr>
    <tr>
      <td width="20" rowspan="2"><img src="images/1.gif" width="220" height="79"></td>
      <td width="354" height="52"><img src="images/44.gif" width="354" height="52"></td>
      <td width="404" rowspan="2"><img src="images/3.gif" width="204" height="79"></td>
    </tr>
    <tr>
      <td height="13"><img src="images/2.gif" width="354" height="27"></td>
    </tr>
  </table>
  <table width="778" border="0" class="unnamed1">
    <tr>
      <td width="155" scope="col"><div align="center"><a href="admin_ry.asp">人员管理</a></div></td>
      <td width="155" scope="col"><div align="center"><a href="admin_kq.asp">用户定单管理</a></div></td>
      <td width="175" scope="col"><div align="center"><a href="admin_yj.asp">定单管理</a></div></td>
      <td width="155" scope="col"><div align="center"><a href="admin_wt.asp">提款管理</a></div></td>
      <td width="155" scope="col"><div align="center"><a href="<%= MM_Logout %>">退出系统</a></div></td>
    </tr>
  </table>
  <!-- End ImageReady Slices -->
  <p>&nbsp;</p>
  <%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
sql="select * from wt  order by ID desc"
rs.PageSize = 10 '这里设定每页显示的记录数
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1 '这里执行你查询SQL并获得结果记录集
pre = true
last = true
page = trim(Request.QueryString("page"))

if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<%
for i=1 to rs.PageSize
if rs.EOF  or rs.BOF then exit for
%>
<table width="778" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="194" align="center"><%=rs("bt")%></td>
    <td width="194" align="center"><%=rs("nr")%></td>
    <td width="194" align="center"><%=rs("idata")%></td>
    <td width="199" align="center"><%=rs("fyr")%></td>
  </tr>
</table>


<%
rs.movenext
next
%>
循环体结束
分页部分:
<table width="778" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="778" align="right"> <a href="admin_wt.asp?page=1">首页</a>|
<%if pre then%>
<a href="admin_wt.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="admin_wt.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="admin_wt.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="admin_wt.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="admin_wt.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>
</table>
</div>
</BODY>
</HTML> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值