[求助]站内搜索引擎帮着看看谢谢
<% key=replace(replace(replace(trim(request.querystring("serchkey")),"%",""),"""",""),"'","")
sql="select * from tablename where "
n=instr(key," ")
m=0
do while (n>0)
lstr=left(key,n-1)
key=trim(right(key,len(key)-n))
if(m>0) then
sql=sql&" and (名称 like '"&lstr&"' or 说明 like '"&lstr&"' or 产地 like '"&lstr&"')"
else
sql=sql&" (名称 like '"&lstr&"' or 说明 like '"&lstr&"' or 产地 like '"&lstr&"')"
m=1
end if
n=instr(key," ")
loop
if(m>0) then
sql=sql&" and (名称 like '"&key&"' or 说明 like '"&key&"' or 产地 like '"&key&"')"
else
sql=sql&"( 名称 like '"&key&"' or 说明 like '"&key&"' or 产地 like '"&key&"')"
end if
response.write sql
%>