问题解决,原来抄还是有用的
<%public function translate(sourceStr,fieldStr)
rem 处理逻辑表达式的转化问题
dim sourceList
dim resultStr
dim i,j
if instr(sourceStr," ")>0 then '空格判断
dim isOperator
isOperator = true
sourceList=split(sourceStr)
'--------------------------------------------------------
rem Response.Write "num:" & cstr(ubound(sourceList)) & "<br>"
for i = 0 to ubound(sourceList)
rem Response.Write i
Select Case ucase(sourceList(i))
Case "AND","&","和","与"
resultStr=resultStr & " and "
isOperator = true
Case "OR","|","或"
resultStr=resultStr & " or "
isOperator = true
Case "NOT","!","非","!","!"
resultStr=resultStr & " not "
isOperator = true
Case "(","(","("
resultStr=resultStr & " ( "
isOperator = true
Case ")",")",")"
resultStr=resultStr & " ) "
isOperator = true
Case Else
if sourceList(i)<>"" then
if not isOperator then resultStr=resultStr & " and "
if inStr(sourceList(i),"%") > 0 then
resultStr=resultStr&" "&fieldStr& " like '" & replace(sourceList(i),"'","''") & "' "
else
resultStr=resultStr&" "&fieldStr& " like '%" & replace(sourceList(i),"'","''") & "%' "
end if
isOperator=false
End if
End Select
rem Response.write resultStr+"<br>"
next
translate=resultStr
else '单条件
if inStr(sourcestr,"%") > 0 then
translate=" " & fieldStr & " like '" & replace(sourceStr,"'","''") &"' "
else
translate=" " & fieldStr & " like '%" & replace(sourceStr,"'","''") &"%' "
End if
rem 前后各加一个空格,免得连sql时忘了加,而出错。
end if
end function%>
<table width="95%" border="0" cellspacing="0" cellpadding="0" style=" table-layout:fixed;word-break:break-all">
<tr>
<td style="line-height:140%;">
<%set ky=server.CreateObject("adodb.recordset")
ky.open"select zqtitle from wenzhang1 where zqid="&zid,conn,1,1
if not ky.eof then
zqtitle1=ky("zqtitle")
set ky=nothing
if instr(zqtitle1,"|")>1 then
zqtitle1=mid(zqtitle1,cint(instr(zqtitle1,"|"))+1,40)
set tw=server.CreateObject("adodb.recordset")
'sql="select distinct * from wenzhang1 where (" & translate(zqtitle1,"zqtitle") & ") and zqid<>"&zid&" order by addtime desc"
tw.open"select distinct * from wenzhang1 where (" & translate(zqtitle1,"zqtitle") & ") and zqid<>"&zid&" order by addtime desc",conn,1,1
if tw.eof then
Response.Write("没有相关文章")
'Response.Write(sql)
end if
do while not tw.eof
zqtitle=tw("zqtitle")
if instr(zqtitle,"|")>1 then
zqtitle=mid(zqtitle,1,cint(instr(zqtitle,"|"))-1)
end if
%>
<li> <a href="View_net.asp?l=wz&zid=<%= tw("zqid") %>" title="<%= tw("zuozhe") %>:<%= zqtitle %>" target="_blank"><font color="#000099">
<% if len(zqtitle)>12 then
Response.Write(mid(zqtitle,1,12)&"..")
else
Response.Write(zqtitle)
end if
%>
</font></a><font color="#FF0000">[<%= tw("zqcounts") %>]</font>
<% tw.movenext
loop
tw.close
set tw=nothing
else
Response.Write("没有相关文章")
end if
end if %></td>
</tr>
</table>