ASP 相關(guān)文章或者相關(guān)產(chǎn)品
更新時(shí)間:2009年05月29日 20:28:15 作者:
以下僅提供相關(guān)思路和關(guān)鍵代碼,并且只提供一種最簡(jiǎn)單的算法實(shí)現(xiàn),稍復(fù)雜的本文不做介紹。
在后臺(tái)添加中一般我們都設(shè)置了一個(gè)“關(guān)鍵字”,而且一般輸入可能如下:
娃娃,毛絨娃娃,日本充氣娃娃
我們將根據(jù)這個(gè)來做,具體實(shí)現(xiàn)如下:
先看一條SQL語句:
select top 3 sid,sname from product where keywords like '%娃娃%' or keywords like '%毛絨娃娃%' or keywords like '%日本充氣娃娃%'
那么我們根據(jù)這條語句就可以搜索到相關(guān)產(chǎn)品或者相關(guān)文章了(其實(shí)有更復(fù)雜以及更好的實(shí)現(xiàn),但這里暫時(shí)不提及了),以下是關(guān)鍵代碼:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.Charset="gb2312" %>
<%
Dim A:A = "娃娃,毛絨娃娃,日本充氣娃娃"
'obj為值,filed為字段名
Function sqlKeyWord(obj,field)
Dim temp:temp = split(obj,",")
For i = 0 To ubound(temp)
sqlKeyWord = sqlKeyWord & field&" like '%"&temp(i)&"%' or "
Next
sqlKeyWord = left(sqlKeyWord,len(sqlKeyWord)-3)
End Function
Dim mysql:mysql = "select top 3 sid,sname from product where " + sqlKeyWord(A,"keywords")
Response.Write(mysql)
'Set objRs = objConn.execute(mysql)
'Do while not objRs.Eof
'Response.Write(objRs("sname"))
'Loop
'objRs.close
'set objRs = nothing
'objConn.close
'set objConn = nothing
%>
娃娃,毛絨娃娃,日本充氣娃娃
我們將根據(jù)這個(gè)來做,具體實(shí)現(xiàn)如下:
先看一條SQL語句:
復(fù)制代碼 代碼如下:
select top 3 sid,sname from product where keywords like '%娃娃%' or keywords like '%毛絨娃娃%' or keywords like '%日本充氣娃娃%'
那么我們根據(jù)這條語句就可以搜索到相關(guān)產(chǎn)品或者相關(guān)文章了(其實(shí)有更復(fù)雜以及更好的實(shí)現(xiàn),但這里暫時(shí)不提及了),以下是關(guān)鍵代碼:
復(fù)制代碼 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.Charset="gb2312" %>
<%
Dim A:A = "娃娃,毛絨娃娃,日本充氣娃娃"
'obj為值,filed為字段名
Function sqlKeyWord(obj,field)
Dim temp:temp = split(obj,",")
For i = 0 To ubound(temp)
sqlKeyWord = sqlKeyWord & field&" like '%"&temp(i)&"%' or "
Next
sqlKeyWord = left(sqlKeyWord,len(sqlKeyWord)-3)
End Function
Dim mysql:mysql = "select top 3 sid,sname from product where " + sqlKeyWord(A,"keywords")
Response.Write(mysql)
'Set objRs = objConn.execute(mysql)
'Do while not objRs.Eof
'Response.Write(objRs("sname"))
'Loop
'objRs.close
'set objRs = nothing
'objConn.close
'set objConn = nothing
%>
相關(guān)文章
ASP中實(shí)現(xiàn)定時(shí)發(fā)送郵件的代碼分享
這篇文章主要介紹了ASP中實(shí)現(xiàn)定時(shí)發(fā)送郵件的代碼分享,使用VBS的方式實(shí)現(xiàn),并運(yùn)行在數(shù)據(jù)庫中,需要的朋友可以參考下2014-07-07數(shù)據(jù)庫記錄的刪除,delete好還是update好?
數(shù)據(jù)庫記錄的刪除,delete好還是update好?...2006-10-10ASP生成數(shù)字相加求和的BMP圖片驗(yàn)證碼
以前我自己寫了個(gè)是文字的,但還是這個(gè)好,都是圖片的2008-08-08ASP FSO顯示特殊文件夾的實(shí)現(xiàn)代碼(畸形目錄名、UNC路徑)
一些特殊的文件夾asp是沒法完全顯示出來的,但是可以通過unc路徑去刪除,但前提是得知道準(zhǔn)確路徑2012-03-03asp連接SQL和Access數(shù)據(jù)代碼(asp里的隨機(jī)函數(shù))
asp連接SQL和Access數(shù)據(jù)代碼,asp里的隨機(jī)函數(shù),需要的朋友可以參考下2012-09-09