给我一段查询的代码
就是可以提供用户选择要查询字段的功能(下拉框);
还有对这些选择的字段可以提供方便的查询条件输入或选择(如大于 小于 模糊 等等);
---------------------------------------------------------------
///生成查询方式
function setFindPrecision(){
//删除列表中所有项目////////////
var alllength=query.FindPrecision.length
i=0
while (i
1<alllength){ (l_str="003" ){="" i="i+1" if="" l_str="135" option("大于","="" query.findprecision.options[0]="new" }="" ¦="">")
2query.FindPrecision.options[1]=new Option("等于","=")
3query.FindPrecision.options[2]=new Option("小于","<")
4}
5else{
6query.FindPrecision.options[0]=new Option("模糊","模糊")
7query.FindPrecision.options[1]=new Option("精确","精确")
8}
9}
10\---------------------------------------------------------------
11
12给个例子你看:
@language="VBScript"
set rs=server.createobject("adodb.recordset")
if request("id")<>"" then
searchKeyWord=request("search")
if searchKeyWord="" then
response.redirect "error.asp?id=19"
response.end
end if
bid= request("site") '版面
ok= request("R1") '查寻方式
id= request("id") '查寻的版面
'查寻用户名开始
select case id
case 1
if ok=1 then '模糊查寻
if bid=0 then
sqlstr="select * from tb_Topic where username like'%" & searchKeyWord &"%'"
else
sqlstr="select * from tb_Topic where username like'%" & searchKeyWord &"%' and bid=" & bid
end if
else '确精查寻
if bid=0 then
sqlstr="select * from tb_Topic where username='" & searchKeyWord &"'"
else
sqlstr="select * from tb_Topic where username='" & searchKeyWord &"' and bid="&bid
end if
end if
case 2 '查寻主题
if ok=1 then '模糊查寻
if bid=0 then
sqlstr="select * from tb_Topic where title like'%" & searchKeyWord &"%'"
else
sqlstr="select * from tb_Topic where title like'%" & searchKeyWord &"%' and bid=" & bid
end if
else '确精查寻
if bid=0 then
sqlstr="select * from tb_Topic where title='" & searchKeyWord &"'"
else
sqlstr="select * from tb_Topic where title='" & searchKeyWord &"' and bid="&bid
end if
end if
case 3 '查寻内容
if ok=1 then '模糊查寻
if bid=0 then
sqlstr="select * from tb_Topic where content like'%" & searchKeyWord &"%'"
else
sqlstr="select * from tb_Topic where content like'%" & searchKeyWord &"%' and bid=" & bid
end if
else '确精查寻
if bid=0 then
sqlstr="select * from tb_Topic where content='" & searchKeyWord &"'"
else
sqlstr="select * from tb_Topic where content='" & searchKeyWord &"' and bid="&bid
end if
end if
end select
else
username=request("user") '发贴用户名
sqlstr="select * from tb_Topic where username='" & username &"'"
end if
rs.open sqlstr,conn,1,1
'存用户发贴主题表中的所有记录*****
1<div align="center">
2<table border="0" cellspacing="1" width="692">
3<tr>
4<td height="35" valign="top" width="345">
5<p align="left"><img src="images/open.gif"/><a href="index.asp">论坛首页<br/>
6</a><font size="2"><img border="0" src="images/tline.gif"/></font><img src="images/open.gif"/>论坛贴子搜索</p>
7</td>
8<td height="35" width="345">
9<a href="index.asp?login=2">会员登录</a> ¦<a href="reg.asp">会员注册</a> ¦<a href="editbio.asp">修改资料</a> ¦<a href="getpassword.asp">忘记了密码</a> ¦<a href="searchboard.asp">文章搜索</a> ¦<a href="memberlist.asp?sort=top">会员列表</a>
10</td>
11<tr>
12<tr>
13<td width="345"><font color="#660000"><span style="font-size: 10.5pt"><br/>
14搜索结果</span></font>:共有<font color="#0000FF">[```
15=rs.recordcount
16```]</font>篇文章</td>
17<td align="right" width="345">新搜索 ¦ <a href="./"> 回论坛首页</a>
18</td></tr></tr></tr></table>
19<table cellpadding="0" cellspacing="0" height="47" width="90%"><tr><td>
20<table border="0" cellpadding="3" cellspacing="1" width="100%">
21<tr bgcolor="666666">
22<td bgcolor="#008080" width="52%">
23<p align="center"><font color="#FFFFFF">主题</font></p>
24</td>
25<td align="center" bgcolor="#008080" width="18%"><font color="#FFFFFF">用户名</font></td>
26<td align="center" bgcolor="#008080" width="15%"><font color="#FFFFFF">日期</font></td>
27<td align="center" bgcolor="#008080" width="15%"><font color="#FFFFFF">论坛/归档</font></td>
28</tr>
dim n
n=1
set rs1=server.createobject("adodb.recordset")
do while not rs.eof
if n=1 then
response.write "<tr bgcolor="#EAEAEA">"
else
response.write "<tr bgcolor="#FFFFFF">"
end if
n=1-n
1<td align="center"><p align="left">◎<a ```"="" href="show.asp?id=```
2 =rs(" id")="">```
3=rs("title")
4```</a></p></td>
5<td align="center">```
6 =rs("username")
7```</td>
8<td align="center">```
9 =year(rs("ldate"))&amp;"-"&amp;month(rs("ldate"))&amp;"-"&amp;day(rs("ldate"))
10```</td>
11<td align="center">
bid=rs("bid")
sqlstr="select * from tb_Board where bid=" & bid
rs1.open sqlstr,conn,1,1
response.write rs1("cname")
rs1.close
1</td>
rs.movenext
loop
rs.close
set rs1=nothing
set rs=nothing
1</tr></tr></table>
2</td>
3</tr>
4</table><center><br/></center></div>
5<script>Layer_Loading.style.visibility="hidden";</script></body></html></alllength){>