ASP+access数据库价格区段排序的问题
大家好,我是菜鸟,想学一下ASP语言,请大家多多帮忙啊!!!我的access数据库是data.mdb,表是tade,字段有五个,aa, bb,都是备注 cc,dd类型都是数字。
id(自动编码) aa(产品名称) bb(省份) cc(价格/斤) dd(级别)
1 花生 广东省 6.00元 1
2 花生 广西省 185.00元 8
3 花生油 广西省 58.00元 15
搜索条如下图:
我想达到的功能是1、按价格从低到高,2、按级别从低到高,3、1元-100元,4、100元-200元 5、200元-300元,现在的代码按价格从低到高和按级别从低到高都可以,就是1元-100元,100元-200元,200元-300元这些区段的语句代码不会写,望高手指点..分数不多了全给了,谢谢!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<table width=690 border="0" cellspacing="0" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="100%" style="word-break:break-all" align="center">
<tr>
<td width="590" align="center" colspan="7">
<form method="POST" name="form1" action=sou.asp>
<P><font style="font-size: 14px " color="0000ff" align="left">搜索内容</font>
<input type="text" name="aa" size="15" id="aa"value="<%=request("aa")%>">
<select name="bb" id="bb">
<option selected="selected" value="">所在地区</option>
<option value="广东" <%if Request("bb")="广东" then Response.write "selected"%>>广东</option>
<option value="江苏" <%if Request("bb")="江苏" then Response.write "selected"%>>江苏</option>
</select>
<select name="dd" id="dd">
<option selected="selected" value="">等级分类</option>
<option value="4" <%if Request("dd")="1" then Response.write "selected"%>>一级</option>
<option value="3" <%if Request("dd")="2" then Response.write "selected"%>>二级</option>
<option value="2" <%if Request("dd")="3" then Response.write "selected"%>>三级</option>
</select>
<select name="cc" id="cc">
<option selected="selected" value="">默认排序</option>
<option value="251" <%if Request("cc")="251" then Response.write "selected"%>>按价格从低到高</option>
<option value="99999991" <%if Request("cc")="99999991" then Response.write "selected"%>>按级别从高到低</option>
<option value="99999992" <%if Request("cc")="99999991" then Response.write "selected"%>>按级别从低到高</option>
<option value="250" <%if Request("cc")="250" then Response.write "selected"%>>按价格从高到低</option>
<option value="100" <%if Request("cc")="100" then Response.write "selected"%>>1元-100元区</option> <option value="100" <%if Request("cc")="100" then Response.write "selected"%>>100元-200元区</option> <option value="200" <%if Request("cc")="200" then Response.write "selected"%>>200元-300元区</option>
</select></select><input type="submit" value="搜索" name="B1"></form>
</tr>
</table>
<TABLE width=690 bgColor=#FFFFFF border=0 bordercolor="0" align="center">
<TR>
<TD>
<%
aa=request.form("aa")
bb=request.form("bb")
dd=request.form("dd")
cc=request.form("cc")
dim pageCount
page = cint(request("page"))
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("data.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql="select * from tade where 1=1 "
Dim SearchStr
if aa <> "" then
sql=sql&"and minqing like '%"&aa& "%'"
end if
if bb<>"" then
sql=sql&"and dindi like '%"&bb&"%'"
end if
if dd<>"" then
sql=sql&"and guang like '%"&dd&"%'"
end if
if cc="" then
sql=sql&" order by id desc"
end if
if cc="251" then
sql=sql&" order by ping asc"
end if
if cc="99999991" then
sql=sql&" order by guang desc"
end if
if cc="99999992" then
sql=sql&" order by guang asc"
end if
if cc="250" then
sql=sql&" order by ping desc"
end if
if cc="100" then
sql=sql&" order by ping between 1 and 100 desc"
end if
if cc="200" then
sql=sql&" order by ping between 100 and 200 desc"
end if
rs.open sql,conn,3,3
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有该商品记录,请返回."
response.end
end if
RS.PageSize=8
pageCount = cint(rs.pageCount)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>
<tr>
<td width="160" >
<div align="center"><font style="font-size: 13px">价格:</font><font style="font-size: 16px" color="#ff0000"><strong><%=rs("ping")%>元</strong></font></div>
</tr>
</td>
<tr>
</tr></div>
</table></div>
<%RS.MoveNext
NumRows=NumRows+1
WEND%>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>