jeudi 12 mai 2016

how to show result by highest matching keywords result first using asp classic

I want to show result sorting by highest matching keywords result should come first and then second highest matching keywords result should come next like this...

below code show result but not in sorting as what i mentioned above.

please help me to resolve this issue as i don't want to use full text index

my code is as below given:

<%
Dim SearchWord, arrKeyWords, Cnt, tsearch, i
SearchWord = trim(request("searcha"))
SearchWord = replace(SearchWord, " and ", " ")
SearchWord = replace(SearchWord, " in ", " ")
SearchWord = replace(SearchWord, " or ", " ")
arrKeyWords = Split(SearchWord ," ") 
%>
<%
If IsArray(arrKeyWords) Then
For i = 0 To (UBound(arrKeyWords)-1)

Dim objRSsg, objCmdsg, strsg
Set objCmdsg  = Server.CreateObject("ADODB.Command")
Set objRSsg  = Server.CreateObject("ADODB.Recordset")

dim countItem, numPerPage, page, totalpages, totalRecs
countItem = 0
numPerPage = 50

objRSsg.cursorlocation = 3
if request("page") = "" then
page=1
else
page=CLng(request("page"))
end if
strsg = "select rProd_name, r_id from reseller_prod where rProd_name LIKE '%' + ? + '%' union select Prod_name, '' as r_id from product where Prod_name LIKE '%' +  ? + '%'"

With objCmdsg
.ActiveConnection = MM_connDUdirectory_STRING
.CommandText = strsg
.CommandType = adCmdText
.Parameters.Append(.CreateParameter("@sa1", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa2", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa3", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa4", adVarChar, adParamInput, 1000))

.Parameters("@sa1").Value = arrKeyWords(i)
.Parameters("@sa2").Value = arrKeyWords(i)
.Parameters("@sa3").Value = arrKeyWords(i)
.Parameters("@sa4").Value = arrKeyWords(i) 

end with 
objRSsg.Open objCmdsg, , 1, 2
next
end if
....
....
%>

Aucun commentaire:

Enregistrer un commentaire