怎么把加空格的关键字分开搜索 ASP
发布网友
发布时间:2024-09-10 07:40
我来回答
共2个回答
热心网友
时间:2024-11-04 11:46
给你写段例子吧,要加分啊。
<form method="POST" action="">
<p>input1:<input type="text" name="input1" size="20"><input type="submit" value="查询" name="B1"></p>
</form>
<%
if request("input1")<>"" then
input1=trim(request("input1"))
input1=Replace(input1,","," ")
input1=replace(input1,","," ")
aa=split(input1," ")(0)
ab=trim(right(input1,len(input1)-len(aa)))
if ab="" then
ab=aa
end if
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db.mdb")
exec="select * from aaa where input1 like '%"&aa&"%' or input1 like '%"&ab&"%'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%><tr>
<td><%=rs("id")%></td>
<td><%=rs("input1")%></td>
<td><%=rs("input2")%></td>
<td><%=rs("input3")%></td>
<td><%=rs("input4")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%end if%>
热心网友
时间:2024-11-04 11:47
分别把“安”“装”加上引号搜索就可以啦