标题:[求助]相关主题的查找问题
取消只看楼主
滚水六脚
Rank: 1
等 级:新手上路
帖 子:132
专家分:0
注 册:2004-8-16
 问题点数:0 回复次数:2 
[求助]相关主题的查找问题

标题和关键字放在一起的。。。

因为是循环查找,多个关键字对应同一主题时会出现重复数据,有什么办法解决啊?

或用其他办法应该怎么做啊?(标题和多个关键字放在一起的)

<!--#include file="conn.asp"--> <table width="95%" border="0" cellspacing="0" cellpadding="0" style=" table-layout:fixed;word-break:break-all"> <tr> <td style="line-height:140%;"> <%zid=Trim(Request("zid")) 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,"|")<>0 then fg=split(zqtitle1,"|") for i=1 to ubound(fg) if fg(i)<>"" then set tw=server.CreateObject("adodb.recordset") tw.open"select distinct * from wenzhang1 where zqtitle like '%"&fg(i)&"%' and zqid<>"&zid&" order by addtime desc",conn,1,1 do while not tw.eof zqtitle=tw("zqtitle") if instr(zqtitle,"|")<>0 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 end if next else Response.Write("没有相关文章") end if end if %></td> </tr> </table>

搜索更多相关主题的帖子: 主题 
2004-11-09 15:57
滚水六脚
Rank: 1
等 级:新手上路
帖 子:132
专家分:0
注 册:2004-8-16
得分:0 

有那位有相关资料,发个上来看看,找了很久没找到适合的,谢谢

2004-11-09 17:12
滚水六脚
Rank: 1
等 级:新手上路
帖 子:132
专家分:0
注 册:2004-8-16
得分:0 

问题解决,原来抄还是有用的

<%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>

2004-11-10 16:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-7362-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053704 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved