如何在asp页面分页显示数据库信息

2024-12-23 08:01:39
推荐回答(1个)
回答1:





<%on error resume next%>











<%
if request.querystring("act")="tijiao" then
if not session("acc") then
response.write("请先登录")
else
rst.open "liuyan",conn,1,3
rst.addnew
rst("l_id")=session("ID")
rst("l_sj")=now
rst("l_ly")=request.form("b_ly")
rst.update
rst.close
if err.number>0 then
response.write("留言不能为空")
else
response.Redirect("liuyan.asp")
'response.write("留言提交成功")
end if
end if
end if
%>



留言

<%
set rst=server.createobject("adodb.recordset")
rst.open "select * from liuyan order by l_uid desc",conn,1.1
dim uid
uid=request.querystring("uid")
if request.querystring("act")="shanchu" then
set rst1=server.createobject("adodb.recordset")
rst1.open "select * from liuyan where l_uid="&uid,conn,1,3
rst1.delete
rst1.close
response.Redirect("liuyan.asp")
'response.write("留言删除成功")
end if %>



<% If not rst.eof Then
tol=rst.recordcount
shownum=15
rst.pagesize=shownum
maxpage=rst.pagecount
requestpage=clng(request("p"))
if requestpage="" or requestpage<1 then
requestpage=1
end if
if requestpage>maxpage then
requestpage=maxpage
end if
if not requestpage=1 then
rst.move (requestpage-1)*rst.pagesize
end if
for i=1 to rst.pagesize and not rst.eof

%>











<%
rst.movenext
if rst.eof then exit for
next
else
response.Write("没有您要查询的信息!")
end if

%>
<%response.write("用户:" & rst("l_id"))%> <%=rst("l_sj")%>

<%response.write("说:" & rst("l_ly"))%>
<%if session("ID")="hwbshuaige134" then%>
" target="kj" class="STYLE1">删除
<%end if%>






<%Rst.Close
Set Rst=Nothing%>

共<%=tol %>条记录 共<%=maxpage%>页 第<%=requestpage%>页
<%if requestpage-1>0 then%>
上一页
<%else%>
上一页
<%end if%>
<%if requestpage+1<=maxpage then%>
下一页
<%else%>
下一页

<%end if%>






在此写留言









<%
set rst=nothing
conn.close
set conn=nothing
%>




试试这个