ASP高手请进-分页显示记录
<!--#includefile="conn.asp"--><%dimpagesizepagesize=4dimtotalpagedimpagedimrsdimsqldi...
<!--#include file="conn.asp"-->
<%dim pagesize
pagesize=4
dim totalpage
dim page
dim rs
dim sql
dim i ,j
if request("page")="" then
page=1
else page=cint(request("page"))%>
<%
set rs=server.CreateObjcet("adodb.recordset")
sql="select * from user"
rs.open sql,conn,1,3
rs.pagesize=pagesize
totalpage=rs.pagecount
%>
<%if not rs.eof then
rs.absolutepage=page%>
<html>
<body>
<% response.write "姓名 , 密码"
for i=1 to rs.pagesize
if rs.eof then exit for
response.write rs("名字")
rs.movenext
next
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%end if%>
<%response.write "共"&totalpage&"页,当前为第"&page&"页"
if page>1 then
response.write "<a href=a.asp?page="&page-1&">上页</a>"
end if
if page<totalpage then
response.write "<a href=a.asp?page="&page+1&">下页></a>"
end if %>
</body>
</html>
本人初学ASP,处理分页显示记录出现问题,但不知道要怎么解决,请各位高手帮忙一下,谢谢
无法显示出数据... 展开
<%dim pagesize
pagesize=4
dim totalpage
dim page
dim rs
dim sql
dim i ,j
if request("page")="" then
page=1
else page=cint(request("page"))%>
<%
set rs=server.CreateObjcet("adodb.recordset")
sql="select * from user"
rs.open sql,conn,1,3
rs.pagesize=pagesize
totalpage=rs.pagecount
%>
<%if not rs.eof then
rs.absolutepage=page%>
<html>
<body>
<% response.write "姓名 , 密码"
for i=1 to rs.pagesize
if rs.eof then exit for
response.write rs("名字")
rs.movenext
next
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%end if%>
<%response.write "共"&totalpage&"页,当前为第"&page&"页"
if page>1 then
response.write "<a href=a.asp?page="&page-1&">上页</a>"
end if
if page<totalpage then
response.write "<a href=a.asp?page="&page+1&">下页></a>"
end if %>
</body>
</html>
本人初学ASP,处理分页显示记录出现问题,但不知道要怎么解决,请各位高手帮忙一下,谢谢
无法显示出数据... 展开
6个回答
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
mypage=request.Querystring("whichpage")
if mypage="" then
mypage=1
end if
mypagesize=request.QueryString("pagesize")
if mypagesize="" then
mypagesize=5
end if
rs.movefirst
rs.pagesize=mypagesize
maxcount=cint(rs.pagecount)
rs.absolutepage=mypage
d=rs.recordcount
how=0
qx=rs.recordcount
%>
<%if rs.eof then%>
暂无记录
<%response.end()
end if%>
<%do while not rs.eof and how <rs.pagesize%>
<%rs.movenext
how=how+1
loop
<%
if mypage<>1 then
response.write"<a href=cpjs.asp>[第一页]</a>"
response.write"<a href=cpjs.asp?whichpage="&(mypage-1)&">[上一页]</a>"
end if
if mypage<>rs.pagecount then
response.write"<a href=cpjs.asp?whichpage="&(mypage+1)&">[下一页]</a>"
response.write"<a href=cpjs.asp?whichpage="&(rs.pagecount)&">[最后一页]</a>"
end if
%>
当前为第<%=mypage%>/<%=maxcount%>页 共有<%=maxcount%>页
<%for i=1 to maxcount%>
<a href="cpjs.asp?whichpage=<%=i%>"><%=i%></a>
<%next%>
共有<%=qx%>条记录
%>
if mypage="" then
mypage=1
end if
mypagesize=request.QueryString("pagesize")
if mypagesize="" then
mypagesize=5
end if
rs.movefirst
rs.pagesize=mypagesize
maxcount=cint(rs.pagecount)
rs.absolutepage=mypage
d=rs.recordcount
how=0
qx=rs.recordcount
%>
<%if rs.eof then%>
暂无记录
<%response.end()
end if%>
<%do while not rs.eof and how <rs.pagesize%>
<%rs.movenext
how=how+1
loop
<%
if mypage<>1 then
response.write"<a href=cpjs.asp>[第一页]</a>"
response.write"<a href=cpjs.asp?whichpage="&(mypage-1)&">[上一页]</a>"
end if
if mypage<>rs.pagecount then
response.write"<a href=cpjs.asp?whichpage="&(mypage+1)&">[下一页]</a>"
response.write"<a href=cpjs.asp?whichpage="&(rs.pagecount)&">[最后一页]</a>"
end if
%>
当前为第<%=mypage%>/<%=maxcount%>页 共有<%=maxcount%>页
<%for i=1 to maxcount%>
<a href="cpjs.asp?whichpage=<%=i%>"><%=i%></a>
<%next%>
共有<%=qx%>条记录
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你是哪里不懂 还是每句都不懂
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这是我的,你可以借鉴一下:
<%set rs=server.CreateObject("adodb.recordset")
sql="select * from message order by insdate desc "
rs.open sql,conn,1,1
dim page
page=request("page")
if page="" then
page=1
end if
rs.pagesize=2
rs.absolutepage=page
dim i
i=1
do while not rs.eof and i<=2
%>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td width="11%" height="20">留言者: </td>
<td width="40%" height="20"><a target="_blank"href="message_index.asp?id=<%=rs("id")%>"><%=rs("liuname")%></a></td>
<td width="14%">留言时间:</td>
<td width="35%"><%=rs("insdate")%></td>
</tr>
<tr>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td colspan="4"> </td>
<%rs.movenext
i=i+1
loop
%>
</tr>
<tr align="right">
<td height="25" colspan="4" class="top_m_txt01"><a href="message.asp?page=1">首页</a>
<%if page>1 then%>
<a href="message.asp?page=<%=page-1%>">上一页</a>
<%end if%>
<%if cint(page)<rs.pagecount then%>
<a href="message.asp?page=<%=page+1%>">下一页</a>
<%end if%>
<a href="message.asp?page=<%=rs.pagecount%>">末页</a><br>
当前页<%=page%>/<%=rs.pagecount%> 共有<%=rs.recordcount%>条记录 共有<%=rs.pagecount%>页</td>
</tr>
</table>
<%set rs=server.CreateObject("adodb.recordset")
sql="select * from message order by insdate desc "
rs.open sql,conn,1,1
dim page
page=request("page")
if page="" then
page=1
end if
rs.pagesize=2
rs.absolutepage=page
dim i
i=1
do while not rs.eof and i<=2
%>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td width="11%" height="20">留言者: </td>
<td width="40%" height="20"><a target="_blank"href="message_index.asp?id=<%=rs("id")%>"><%=rs("liuname")%></a></td>
<td width="14%">留言时间:</td>
<td width="35%"><%=rs("insdate")%></td>
</tr>
<tr>
<td colspan="4"><hr size="1"></td>
</tr>
<tr>
<td colspan="4"> </td>
<%rs.movenext
i=i+1
loop
%>
</tr>
<tr align="right">
<td height="25" colspan="4" class="top_m_txt01"><a href="message.asp?page=1">首页</a>
<%if page>1 then%>
<a href="message.asp?page=<%=page-1%>">上一页</a>
<%end if%>
<%if cint(page)<rs.pagecount then%>
<a href="message.asp?page=<%=page+1%>">下一页</a>
<%end if%>
<a href="message.asp?page=<%=rs.pagecount%>">末页</a><br>
当前页<%=page%>/<%=rs.pagecount%> 共有<%=rs.recordcount%>条记录 共有<%=rs.pagecount%>页</td>
</tr>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<SCRIPT LANGUAGE="JavaScript">
<!--
function GON()
{
var pageno;
var strs;
if(form2.pp.value=="")
{
pageno=1;
}
else
{
pageno=form2.pp.value;
}
strs="列表页面.asp?PageNO=" + pageno;
window.location.href=strs;
}
//-->
</SCRIPT>
<%
dim strSql,rs,i,PageNo
if request("pass")="" and request("bh")="" then
strSql="select * from [库表名] where qy='江岸区'and rental1='否' order by id desc" 'adnu='栋号''
else
strSql="select * from [库表名] where qy='江岸区'and rental1='否' " & pass1 & bh1 & " order by id desc" 'adnu='栋号''
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open strSql,conn,3,3
rs.PageSize=16
PageNo=request("PageNo")
if PageNo<1 or not isnumeric(PageNo) then
PageNo=1
end if
if cint(PageNo)>rs.PageCount then
PageNo=rs.PageCount
end if
%>
列表标题
<%
if rs.recordcount>0 then
rs.AbsolutePage =PageNo
for i=1 to rs.pageSize
if rs.eof then exit for
%>
列表内容(也就是调数据库数据)
<%
rs.movenext
next
%>
<%
out("<font color=#000000>当前页次:</font><font color=red>" & PageNo & "/" & rs.pagecount & "</font> ")
out("<font color=#000000>共</font><font color=red>" & rs.pagecount & "</font><font color=#000000>页</font> ")
out("<font color=#000000>共</font><font color=red>" & rs.recordcount & "</font><font color=#000000>条记录</font> ")
out("<font color=#000000>每页显示</font><font color=red>" & rs.pagesize & "</font><font color=#000000>条</font> ")
out("到第 <input class=""textbotton"" name=""pp"" type=""text"" size=""2""> 页")
out(" <INPUT class=""textinput"" TYPE=""button"" value=""GO"" onclick=""javascript:GON()""> ")
out("<a href=""列表页面.asp?PageNo=1"">首页</a> ")
out("<a href=""列表页面.asp?PageNo=" & (PageNo-1) & """>上一页</a> ")
out("<a href=""列表页面.asp?PageNo=" & (PageNo+1) & """>下一页</a> ")
out("<a href=""列表页面.asp?PageNo=" & rs.pagecount & """>尾页</a> ")
%>
<!--
function GON()
{
var pageno;
var strs;
if(form2.pp.value=="")
{
pageno=1;
}
else
{
pageno=form2.pp.value;
}
strs="列表页面.asp?PageNO=" + pageno;
window.location.href=strs;
}
//-->
</SCRIPT>
<%
dim strSql,rs,i,PageNo
if request("pass")="" and request("bh")="" then
strSql="select * from [库表名] where qy='江岸区'and rental1='否' order by id desc" 'adnu='栋号''
else
strSql="select * from [库表名] where qy='江岸区'and rental1='否' " & pass1 & bh1 & " order by id desc" 'adnu='栋号''
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open strSql,conn,3,3
rs.PageSize=16
PageNo=request("PageNo")
if PageNo<1 or not isnumeric(PageNo) then
PageNo=1
end if
if cint(PageNo)>rs.PageCount then
PageNo=rs.PageCount
end if
%>
列表标题
<%
if rs.recordcount>0 then
rs.AbsolutePage =PageNo
for i=1 to rs.pageSize
if rs.eof then exit for
%>
列表内容(也就是调数据库数据)
<%
rs.movenext
next
%>
<%
out("<font color=#000000>当前页次:</font><font color=red>" & PageNo & "/" & rs.pagecount & "</font> ")
out("<font color=#000000>共</font><font color=red>" & rs.pagecount & "</font><font color=#000000>页</font> ")
out("<font color=#000000>共</font><font color=red>" & rs.recordcount & "</font><font color=#000000>条记录</font> ")
out("<font color=#000000>每页显示</font><font color=red>" & rs.pagesize & "</font><font color=#000000>条</font> ")
out("到第 <input class=""textbotton"" name=""pp"" type=""text"" size=""2""> 页")
out(" <INPUT class=""textinput"" TYPE=""button"" value=""GO"" onclick=""javascript:GON()""> ")
out("<a href=""列表页面.asp?PageNo=1"">首页</a> ")
out("<a href=""列表页面.asp?PageNo=" & (PageNo-1) & """>上一页</a> ")
out("<a href=""列表页面.asp?PageNo=" & (PageNo+1) & """>下一页</a> ")
out("<a href=""列表页面.asp?PageNo=" & rs.pagecount & """>尾页</a> ")
%>
参考资料: 看不懂可加我QQ:799219661
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询