我做了二手房查询,做查询的时候遇到麻烦了!

sisiz 2003-10-23 09:10:49
我下面的代码只能查数据库里有的记录,如果数据库里满足条件的记录的话就出错!

<!--#include file="../conn.asp"-->
<%'

pageno=request.querystring("pageno")
pmcount=6
quyu=request("quyu")
ceng=request("ceng")
fw=request("fw")
huxing=request("huxing")
zs=request("zs")
img=request("img")

'查询新城区
if quyu="不限" then
sql="select * from minyong order by riqi desc"
elseif quyu<> "不限" and ceng="不限" and huxing="不限" and fw="不限" then
sql="select * from minyong where quyu='" & quyu &"'"
elseif quyu<>"不限" and ceng<>"不限" and huxing="不限" and fw="不限" then
sql="select * from minyong where quyu='" & quyu &"' and ceng='" & ceng &"'"
elseif quyu<>"不限" and fw<>"不限" and ceng="不限" then
sql="select * from minyong where quyu='" & quyu &"' and fw='" & fw &"'"
elseif quyu<>"不限" and fw<>"不限" and ceng<>"不限" and huxing="不限" then
sql="select * from minyong where quyu='" & quyu &"' and ceng='" & ceng &"' and fw='" & fw &"'"
else
response.Write("没有满足条件的记录!")
end if



rs.open sql,Conn,1,1
rs.pagesize=pmcount
mpage=rs.pagecount

if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then
pageno=1
end if

rs.absolutepage=pageno

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">td{font-size:12px}</style>
<title>无标题文档</title>
</head>
<body bgcolor="#EBD7FF">
<table width="100%" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#0099FF">
<tr align="center" valign="middle">
<td height="40" colspan="8" bgcolor="#3399FF">您查询的是民用住宅二手房信息</td>
</tr>
<tr align="center" valign="middle">
<td width="14%" height="35"><font color="#9900CC">区域</font></td>
<td width="11%" height="35"><font color="#9900CCC">楼层</font></td>
<td width="11%" height="35"><font color="#9900CC">面积</font></td>
<td width="15%" height="35"><font color="#9900CC">户型</font></td>
<td width="17%" height="35"><font color="#9900CC">出租/出售</font></td>
<td width="8%" height="35"><font color="#9900CC">备注</font></td>
<td width="11%"><font color="#9900CC">日期</font></td>
<td width="13%"><font color="#9900CC">出租/出售情况</font></td>
</tr>
<%
rc=rs.pagesize
re=1
do while not rs.eof and rc>0

quyu=rs("quyu")
mj=rs("mj")
ceng=rs("ceng")
fw=rs("fw")
huxing=rs("huxing")
img=rs("img")
%>
<tr align="center" valign="middle">
<td height="15"><%=rs("quyu")%> </td>
<td height="15"><%=rs("ceng")%> </td>
<td height="15"><%=rs("mj")%> </td>
<td height="15">
<%if img<>"" then%>
<a href="<%=rs("../img")%>"><%=rs("huxing")%></a>
<%else%>
<%=rs("huxing")%><br> <font color="#990000">暂没有户型图 </font>
<%end if%>
 </td>
<td height="15"><%=rs("zs")%> </td>
<td height="15"><%=rs("memo")%> </td>
<td height="15"><%=rs("riqi")%> </td>
<td height="15"><%=rs("biaozhi")%> </td>

</tr>
<%
rs.movenext

re=re+1
rc=rc-1
loop
%>
<tr align="right" valign="middle">
<td height="8" colspan="8">
<% for pno=1 to mpage
if pno=cint(pageno) then%>
<%=pno%>
<%else%>
<b><a href='../serach1.asp?pageno=<%=pno%>'><%=pno%></a></b>
<%end if%>
<%next%>
</td>
</tr>

</table>

</body>
</html>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
...全文
56 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxrl 2003-10-23
  • 打赏
  • 举报
回复
'查询新城区
if quyu="不限" then ////这一句话都包含了下面的条件,所以只能执行到这里,再加上一些限制条件。
sql="select * from minyong order by riqi desc"
elseif quyu<> "不限" and ceng="不限" and huxing="不限" and fw="不限" then
sql="select * from minyong where quyu='" & quyu &"'"///这个sql语句应该不对吧
elseif quyu<>"不限" and ceng<>"不限" and huxing="不限" and fw="不限" then
sql="select * from minyong where quyu='" & quyu &"' and ceng='" & ceng &"'"
elseif quyu<>"不限" and fw<>"不限" and ceng="不限" then
sql="select * from minyong where quyu='" & quyu &"' and fw='" & fw &"'"
elseif quyu<>"不限" and fw<>"不限" and ceng<>"不限" and huxing="不限" then
sql="select * from minyong where quyu='" & quyu &"' and ceng='" & ceng &"' and fw='" & fw &"'"
else
response.Write("没有满足条件的记录!")
end if
realplm 2003-10-23
  • 打赏
  • 举报
回复
rs.open sql,Conn,1,1
if rs.eof or rs.bof then
response.write("没有符合条件的记录") '在你操作分页前判断数据集里面是否有数据
else
rs.pagesize=pmcount ‘因为数据集里没有数据 ,所以你这里在没有找到数据时会错
mpage=rs.pagecount
;
;
;
; '分页操作

end if

28,391

社区成员

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

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