请教如何在同一个搜索文本框中输入多关键词(例如中间用空格隔开)的搜索

请教如何在同一个搜索文本框中输入多关键词(例如中间用空格隔开)的搜索,要求每个字或词独立匹配数据库中的字段
---------------------------------------------------------------

可以。
aa=split(request("text")," ")
for i=0 to ubound(aa)
response.write aa(i)
.......
next
---------------------------------------------------------------

文本框中的值——text
set rs=server.createobject("adodb.recordset")
aa=split(request.form("text")," ")
for i=0 to ubound(aa)
sql="select * from yourtable where keywords like '%"&aa(i)&"%'"
rs.open sql,conn,1,1
.......
rs.close
next

当然最好是用存储过程来解决
---------------------------------------------------------------

呵呵用google的搜索方式
关键词用"+"隔开!

你研究一下先

1   
2searthx="s1+s2"   
1   
2  
3searth=replace(searthx,"+"," or searth="&searth&"")   
4  
5Response.Write(searth)   
1<br/>
1<br/>
1 sql="select * from yourtable where searh="&searth&""
1= sql 
Published At
Categories with Web编程
comments powered by Disqus