关于分页查询

anxl 2003-09-29 05:39:41
以下是一个后台查询源码,在执行分页时出现错误?请路过的高手务必帮忙看一下?因为对我来说很重要?非常诚恳的请求!谢谢!
这是查询语句
<%
dim conn
on error resume next
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "dsn=lxd;uid=;pwd=;"
%>
<%
const MaxPerPage=20
dim totalPut
dim category
dim CurrentPage
dim TotalPages
dim i
dim filename
dim categoryid
jm = request.form("jm")
jx =request.form("jx")
nd = request.form("nd")
js = request.form("js")
%>
<%
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
filename="yphj_search.asp"
dim sql
dim rs
if jm <> "" and jx = "" then
condition = "prize.PRIZE like '%" & jm & "%'"
end if
if jx <> "" and jm = "" then
condition = "prize.KIND like '%" & jx & "%'"
end if
if jm <> "" and jx <> "" then
condition = "prize.PRIZE ='" & jm & "' and prize.KIND ='" & jx & "'"
end if
if jm = "" and jx = "" then
condition = "false"
end if

if condition <> "false" then
if nd <> "" then
condition = condition & " and prize.PYEAR =" & Cint(nd)
end if

if js <> "" then
condition = condition & " and prize.Parray =" & Cint(js)
end if

else
if nd <> "" then
condition = " prize.PYEAR =" & Cint(nd)
end if
if js <> "" and condition = "false" then
condition = " prize.Parray =" & Cint(js)
else
if js <> "" then
condition = condition & " prize.Parray =" & Cint(js)
end if
end if
end if

sql = "select lxzlt.zlno as lzlno,lxzlt.Name as orname, lxzlt.Cname as Cname, lxzlt.Director as Director, lxzlt.content as content, lxzlt.hints as hints, lxzlt.lang as lang, lxzlt.minutes as minutes, lxzlt.kinds as kinds,lxzlt.Counts as Counts from lxzlt,prize where lxzlt.zlno = prize.zlno and " & condition

Set RS = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,1
if rs.eof then
response.write "<meta http-equiv=refresh content=""3;URL=yphj.htm""><p align=center><font size=5 color=red>您的请求不存在!页面将在3秒后自动返回。</font></p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if

end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,filename
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,filename
else
currentPage=1
showContent
showpage totalput,MaxPerPage,filename
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
number=maxperpage*(currentpage-1)+1
dim i
i=0

%>
...全文
56 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
anxl 2003-09-29
  • 打赏
  • 举报
回复
费神帮忙看一下谢谢
PeterMCT 2003-09-29
  • 打赏
  • 举报
回复
你贴这么多代码,怎么看的清啊!

anxl 2003-09-29
  • 打赏
  • 举报
回复
可以指出我得代码中的错误吗?如何修改谢谢!
dicklee1214 2003-09-29
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>房间信息</title>
<link href="w.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0">
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>

<td valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="../images/hui/h/h_07.jpg">
<tr>
<td width="98%" height="154" background="../images/hui/h/h_07.jpg" bgcolor="#FFFFFF">
<p align="center"><font size="6">
<img src="../images/hui/zongxingzuren.jpg" width="580" height="48">
<%
PgSz=20
Set Conn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")
conn.Open"dsn=business;uid=businessuser;pwd=businessuser"
strsql="select a.*,b.* from room a,roomrate b where a.roomno=b.roomno"
RS.open strsql,Conn,1,1
If RS.RecordCount=0 then
response.write "<P><center>对不起,数据库中没有相关信息!</center></P>"
else
RS.PageSize = Cint(PgSz)
Total=INT(RS.recordcount / PgSz * -1)*-1
PageNo=Request("pageno")
if PageNo="" Then
PageNo=1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction=Request("ScrollAction")
if ScrollAction="上一页" Then
PageNo=PageNo-1
end if
if ScrollAction="下一页" Then
PageNo=PageNo+1
end if
if PageNo<1 Then
PageNo=1
end if
n=1
RS.AbsolutePage = PageNo
'Response.Write "<CENTER>"
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position<RS.RecordCount then
pagend=position
else
pagend= RS.RecordCount
end if
%>
<img src="../images/hui/fanjiancakan.jpg" width="131" height="34"></font></p>
<div align="center">
<center>
<table width="96%" border="1" cellpadding="2" cellspacing="1" class="unnamed3">
<tr BGCOLOR=#336699>
<td width="13%" align="center"><font color="#FFFFFF">房间代码</font></td>
<td width="14%" align="center"><font color="#FFFFFF">房间面积</font></td>
<td width="20%" align="center"><font color="#FFFFFF">配套家私</font></td>
<td width="20%" align="center"><font color="#FFFFFF">费率(元/天)</font></td>
<td width="16%" align="center"><font color="#FFFFFF">费率(元/周)</font></td>
<td width="17%" align="center"><font color="#FFFFFF">费率(元/月)</font></td>
</tr>
<%
Do while not (RS is nothing)
RowCount=RS.PageSize
Do While Not RS.EOF and rowcount>0
If n=1 then
Response.Write "<TR BGCOLOR=#f0f2f3>"
ELSE
Response.Write "<TR BGCOLOR=#f0f2f3>"
End If
n=1-n
op0=rs("area")
op1=rs("fitment")
op2=rs("oneday")
op3=rs("oneweek")
op4=rs("onemonth")
if len(op0)=0 or isnull(op0) then
op0="无"
end if
if len(op1)=0 or isnull(op1) then
op1="无"
end if
if len(op2)=0 or isnull(op2) then
op2="无"
end if
if len(op3)=0 or isnull(op3) then
op3="无"
end if
if len(op4)=0 or isnull(op4) then
op4="无"
end if
%>
<td width="13%" align="center"><b><%=rs("roomno")%></b> </td>
<td width="14%" align="center"><%=op0%> </td>
<td width="20%" align="center"><%=op1%> </td>
<td width="20%" align="center"><%=op2%> </td>
<td width="16%" align="center"><%=op3%> </td>
<td width="17%" align="center"><%=op4%> </td>
</tr>
<%
RowCount=RowCount-1
RS.MoveNext
Loop
set RS=RS.NextRecordSet
Loop
%>
</table>
</center>
</div>
<form method=post action="room.asp" webbot-action="--WEBBOT-SELF--">
<input type="HIDDEN" name="pageno" value="<%=PageNo%>">
<%
if PageNo>1 Then
response.write "<p align=center><INPUT TYPE=SUBMIT NAME=ScrollAction VALUE=上一页>"
end if
if RowCount=0 and PageNo<>Total then
response.write "<p align=center><INPUT TYPE=SUBMIT NAME=ScrollAction VALUE=下一页>"
end if
response.write "<input type=button value=返回 name=B2 onclick=javascript:history.go(-1)></p>"
End if
Conn.Close
set rs=nothing
set Conn=nothing
%>
</form></td>
<td width="2%"> </td>
</tr>
</table></td>
</tr>
<tr>

<td><img src="../images/hui/h/h_18.jpg" height="12"></td>
</tr>
</table>
</body>

</html>









anxl 2003-09-29
  • 打赏
  • 举报
回复
这是分页代码
<%
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<p align=center><form method=Post action="&filename&"?jm="&jm&"&jx="&jx&"&nd="&nd&"&js="&js&">"
if CurrentPage<2 then
response.write "<font color='999966'>首页   上一页</font>   "
else
response.write "<a href="&filename&"?jm="&jm&"&jx="&jx&"&nd="&nd&"&js="&js&">首页</a>   "
response.write "<a href="&filename&"?page="¤tPage-1&"&jm="&jm&"&jx="&jx&"&nd="&nd&"&js="&js&">上一页</a>   "
end if
if n-currentpage<1 then
response.write "<font color='999966'>下一页   尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&jm="&jm&"&jx="&jx&"&nd="&nd&"&js="&js&">下一页</a>  "
response.write " <a href="&filename&"?page="&n&"&jm="&jm&"&jx="&jx&"&nd="&nd&"&js="&js&">尾页</a>"
end if
response.write "  <font color=red>"¤tPage&"</font>/"&n&" 页 "
response.write " 总共 <font color=red><b>"&totalnumber&"</b></font> 个"
response.write " 转到第 <input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
response.write " 页 <input class=buttonface type='submit' value='Go' name='cmdok'></span></p></form>"

end function
%>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧