The following only provides relevant ideas and key codes, and only provides the simplest algorithm implementation. Slightly more complex algorithms will not be introduced in this article. In the background addition, we usually set a keyword, and the general input may be as follows:
Dolls, stuffed dolls, Japanese inflatable dolls
We will do it based on this, and the specific implementation is as follows:
Let’s look at a SQL statement first:
Copy the code code as follows:
select top 3 sid,sname from product where keywords like '% doll%' or keywords like '%plush doll%' or keywords like '%日本 inflatable doll%'
Then we can search for related products or related articles based on this statement (in fact, there are more complex and better implementations, but we will not mention them here for now). The following is the key code:
Copy the code code as follows:
<%@LANGUAGE=VBSCRIPT CODEPAGE=65001%>
<% Response.Charset=gb2312 %>
<%
Dim A:A = doll, plush doll, Japanese inflatable doll
'obj is the value, filed is the field name
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
%>