一个复合查询的问题求助大家!(在线)先谢了!
两个下拉框和一个文本框,现在文本框可以进行模糊查询,但是就是下拉框的值不知道怎么取,希望大家多多帮助。代码如下:
<form name="form1" action="seater.asp" method="post">
<p><font color="#164DA8"></font>
<input name="hospitalname" type="text" id="hospitalname" >
<input type="submit" name="submit" value="进入选项" style="border: 1px solid #3466BB; background-color: #B6CAEB; color: #3466BB">
</p>
<p><font color="#164DA8">所属区县:
<select name="suoshu" size="1">
<option value="00">全部</option>
<option value="01">东城区</option>
<option value="02">西城区</option>
<option value="03">崇文区</option>
<option value="04">宣武区</option>
<option value="05">朝阳区</option>
<option value="06">丰台区</option>
<option value="07">石景山区</option>
<option value="08">海淀区</option>
<option value="09">门头沟区</option>
<option value="10">房山区</option>
<option value="11">通州区</option>
<option value="12">顺义区</option>
<option value="13">昌平区</option>
<option value="14">大兴区</option>
<option value="15">平谷区</option>
<option value="16">怀柔区</option>
<option value="17">密云县</option>
<option value="18">延庆县</option>
</select>
医院类别:
<select name="leibie" size="1">
<option value="00">全部</option>
<option value="01">对外综合</option>
<option value="02">对外专科</option>
<option value="03">对外中医</option>
<option value="04">社区卫生站</option>
<option value="05">对内</option>
</select>
</font></p>
<%
Set Conn=Server.CreateObject("adodb.Connection")
conn = "PROVIDER=SQLOLEDB;Server=localhost;DATABASE=message;UID=sa;PWD=sa;"
hospitalname=trim(request("hospitalname"))
suoshu=Replace(request.querystring("suoshu"),"'","")
leibie=Replace(request.querystring("leibie"),"'","")
Set RS = Server.CreateObject("ADODB.RecordSet")
sqltemp="Select * from mytable where 1=1"
if hospitalname<>"" then
sqltemp= " select * from mytable where Name like '%" & hospitalname & "%'"
end if
if suoshu<>"" then
sqltemp= " select * from mytable where area like '%" & suoshu & "%' "
end if
if leibie<>"" then
sqltemp=" select * from mytable where level like '%" & leibie & "%' "
end if
if suoshu=01 then
sqltemp=sqltemp & " and area like '东城区%'"
if suoshu=02 then
sqltemp=sqltemp & " and area like '西城区%'"
if suoshu=03 then
sqltemp=sqltemp & " and area like '崇文区%'"
if suoshu=04 then
sqltemp=sqltemp & " and area like '宣武区%'"
if suoshu=05 then
sqltemp=sqltemp & " and area like '朝阳区%'"
if suoshu=06 then
sqltemp=sqltemp & " and area like '丰台区%'"
if suoshu=07 then
sqltemp=sqltemp & " and area like '石景山区%'"
if suoshu=08 then
sqltemp=sqltemp & " and area like '海淀区%'"
if suoshu=09 then
sqltemp=sqltemp & " and area like '门头沟区%'"
if suoshu=10 then
sqltemp=sqltemp & " and area like '房山区%'"
if suoshu=11 then
sqltemp=sqltemp & " and area like '通州区%'"
if suoshu=12 then
sqltemp=sqltemp & " and area like '顺义区%'"
if suoshu=13 then
sqltemp=sqltemp & " and area like '昌平区%'"
if suoshu=14 then
sqltemp=sqltemp & " and area like '大兴区%'"
if suoshu=15 then
sqltemp=sqltemp & " and area like '平谷区%'"
if suoshu=16 then
sqltemp=sqltemp & " and area like '怀柔区%'"
if suoshu=17 then
sqltemp=sqltemp & " and area like '密云县%'"
else
sqltemp=sqltemp & " and area like '延庆县%'"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
if not trim(form1.leibie.value)="00" then
if trim(form1.leibie.value)="01" then
sqltemp=sqltemp & " and type like '对外综合%'"
if trim(form1.leibie.value)="02" then
sqltemp=sqltemp & " and type like '对外专科%'"
if trim(form1.leibie.value)="03" then
sqltemp=sqltemp & " and type like '对外中医%'"
if trim(form1.leibie.value)="04" then
sqltemp=sqltemp & " and type like '社区卫生站%'"
else
if trim(form1.leibie.value)="05" then
sqltemp=sqltemp & " and type like '对内%'"
end if
end if
end if
end if
end if
end if
Rs.CursorLocation=3
rs.open sqltemp,conn,1,3
if not Rs.eof then
Page=request("Page")
if page="" then
page=1
end if
rs.pagesize=20
Rs.AbsolutePage=page
if page<1 then page=1
if page>Rs.AbsolutePage then page=Rs.AbsolutePage
TheMessage ="查询医院 '"&Request.Form("hospitalname") & "' 信息结果如下"
%>
<%
Response.Write "<table width=100% border=0 bgcolor=#164DA8 "_
& "cellspacing=1 cellpadding=2 align=center>"
Response.Write "<tr><td><font color=white><P ALIGN=CENTER>" & TheMessage
Response.Write "</font></td></tr>"
'如果不输出查询结果
Response.Write "</table>"
'如果要输出查询结果
Response.write "<tr bgcolor=white ><td align=center>"
Response.write "<table width=100% bgcolor=#164DA8 " _
& "border=0 cellspacing=1 cellpadding=1 align=center>"
Response.write "<tr><td><font color=white>编号</td>"
Response.write "<td><font color=white>医院名称</font></td>"
Response.write "<td><font color=white>所属区县</font></td>"
Response.write "<td><font color=white>医院类别</font></td>"
Response.write "<td><font color=white>医院等级</font></td>"
for i=1 to rs.pagesize
Response.write "<tr bgcolor=white>"
if rs.eof then exit for
Response.write "<td>" & rs("ID") &"</td>"
Response.write "<td>" & rs("Name") & "</td>"
Response.write "<td>" & rs("area") & "</td>"
Response.write "<td>" & rs("type") & "</td>"
Response.write "<td>" & rs("level") & "</td>"
Response.write "</tr>"
Rs.MoveNext
Next
end if
Response.Write "</table>"
代码多了些,希望大家能够帮助。