跪求一段ASP分页显示记录的代码,要精简易懂的

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:51:48
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
sql="select user,password,username from main "
rs.open sql,conn,1,3
%>
<%do while not rs.eof%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<table width="622" height="89" border="1" align="center">
<tr>
<td width="45">用户名</td>
<td width="230"><%=rs("user")%> </td>
<td width="48">密码</td>
<td width="271"><%=rs("password")%> </td>
</tr>

给你一个小例子看一下
<%
'连接数据库

'执行sql 改你要的sql
set rs=server.CreateObject("adodb.recordset")%>
rs.open "select * from news order by id desc ",conn,1,3

下面的代码就复制用可以了

'分页
i=50
rs.pagesize=i
pu=request("pu")
if pu="" then pu=1
if cint(pu)<="0" then pu=1
if cint(pu)>rs.pagecount then pu=rs.pagecount
if not rs.eof then rs.absolutepage=cint(pu)
'显示记录
if not rs.eof then
do while not rs.eof and i=>1
response.write rs("字段")'显示字段
'就这里改你要的,其它复制用就可以
rs.movenext
i=i-1
loop
end if
%>

当前第 <%=pu%> 页;分
<%=rs.pagecount%> 页;
共 <%=rs.recordcount%> 条记录;
每页<%=i%>条记录
<a href="?pu=1">首 页</a>
<a href="?pu=<%=cint(PU)-1%>">上一页</a>
<a href