以下是代码片段: <% ’================================================= ’过程名:ShowCorrelative ’作 用:显示相关文章 ’参 数:ArticleNum ----最多显示多少篇文章 ’ TitleLen ----标题最多字符数,一个汉字=两个英文字符 ’================================================= sub ShowCorrelative(ArticleNum,TitleLen) dim rs,sql dim strKey,arrKey,i if ArticleNum>0 and ArticleNum<=100 then sql="select top " & ArticleNum else sql="Select Top 5 " end if ’利用"|"符号进行关键字的分割 strKey=mid(rs("Key"),2,len(rs("Key"))-2) if instr(strkey,"|")>1 then arrKey=split(strKey,"|") strKey="((Key like ’%|" & arrKey(0) & "|%’)" for i=1 to ubound(arrKey) strKey=strKey & " or (Key like ’%|" & arrKey(i) & "|%’)" next strKey=strKey & ")" else strKey="(Key like ’%|" & strKey & "|%’)" end if sql= & " ID,Title,Author,date,Hits,L.LayoutFileName From Article A inner join Layout L on L.LayoutID=LayoutID Where Deleted=False and Passed=True and " & strKey & " and ID<>" & ID & " Order by ID desc" Set rs= conn.execute(sql) if TitleLen<0 or TitleLen>255 then TitleLen=50 if rs.bof and rs.Eof then response.write "没有相关文章" else do while not rs.eof response.write "<a href=’" & rs("LayoutFileName") & "?ID=" & rs("ID") & "’ title=’文章标题:" & rs("Title") & vbcrlf & "文章作者:" & rs("Author") & vbcrlf & "更新时间:" & rs("date") & vbcrlf & "点击次数:" & rs("Hits") & "’>" & gotTopic(rs("Title"),TitleLen) & "</a>" rs.movenext loop end if rs.close set rs=nothing end sub %> |