注册 登录
编程论坛 ASP技术论坛

关于价格区间查询的方法请教!

playstar 发布于 2012-12-24 19:29, 541 次点击
程序代码:
  <select name="price">
    <option value="0" selected>均价不限</option>
    <option value="1">2000以下</option>
    <option value="2">2000-2500</option>
    <option value="3">2500-3000</option>
    <option value="4">3000-4000</option>
    <option value="5">4000-5000</option>
    <option value="6">5000-6000</option>
    <option value="7">6000-7000</option>
    <option value="8">7000以上</option>
    </select>

search.asp

<%

  price
=RtnReplaceInt(Request("price"),0)

Select case price
   
Case 1
  Price2
=2000

 
Case 2
  Price1
=2000
  Price2
=2500

 
Case 3
  Price1
=2500
  Price2
=3000

 
Case 4
  Price1
=3000
  Price2
=4000

 
Case 5
  Price1
=4000
  Price2
=5000

 
Case 6
  Price1
=5000
  Price2
=6000

 
Case 7
  Price1
=6000
  Price2
=7000

 
Case 8
  Price1
=7000
End Select


 

  Sql
="select * from NewHouse where sh='1' and len(HouseName)>2 "&citysql&" "

      
If Price1<>"" then
     Sql
=Sql&" and avgprice>="&price1&""
   
End If
   
If Price2<>"" Then
     Sql
=Sql&" and avgprice<="&price2&""
   
End if
      Sql
=Sql&" order by dateandtime desc"
        rs.Open Sql,conn,
1,3

if rs.eof and rs.bof then

 response.write
"<br><li>暂无楼盘!</li>"
else

%>

这个是不是可以进行区间价格查询?
我数据库的表是NewbCn_Fule
需要查询的的数据位这个?
怎么弄呢?


[ 本帖最后由 playstar 于 2012-12-24 19:30 编辑 ]
2 回复
#2
hubowei2012-12-25 07:41
Sql="select * from NewHouse where sh='1' and len(HouseName)>2 "&citysql&" "
 Sql=Sql&" and avgprice>="&price1&""
Sql=Sql&" and avgprice<="&price2&""

我数据库的表是NewbCn_Fule
需要查询的的数据位这个?

怎么没看明白呢
NewbCn_Fule=NewHouse?
#3
playstar2012-12-25 09:10
回复 2楼 hubowei
我放上去后,还是不能查询数据!
1