Forum Moderators: open

Message Too Old, No Replies

Want to log site search queries into DB

         

flyerguy

11:42 am on Mar 13, 2005 (gmt 0)

10+ Year Member



I have a local search function on my ASP storefront. I would like to log what people are entering into the search field, for later analysis to see exactly what people are trying to find.

This is the start of the search results function. After this it pulls up some paged thumbnails, pretty standard stuff:

ElseIf pg = "search" Then
If mode = "" Then
Response.Write img1 & pc
ElseIf mode = "results" Then
If searchBy = "" Then searchBy = "Products"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
sqlsrch = Replace(srch, "XX", "%%%' OR field LIKE '%%%")
If searchBy = "Products" Then sqlQry = "SELECT DISTINCTROW TOP "&maxRecords&" ITEMID, SKU, ITEMNAME, MANUFNAME, THUMBNAIL, DESCRIP FROM qInventoryByManuf WHERE SKU LIKE '%%%"&Replace(sqlsrch, "field", "SKU")&"%%%' OR ITEMNAME LIKE '%

Etc. etc.

I just want to insert a copy of the users entered search phrase into a seperate column in the DB.

Easy_Coder

8:55 pm on Mar 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried appending your search query to perform both activities?

Rem - record the phrase
sqlQry = "insert into foo(test) values(" & sqlsrch & ") "

Rem - search the db...
sqlQry = sqlQry & "SELECT DISTINCTROW TOP "&maxRecords&" ITEMID, SKU, ITEMNAME, MANUFNAME, THUMBNAIL, DESCRIP FROM qInventoryByManuf WHERE SKU LIKE '%%%"&Replace(sqlsrch, "field", "SKU")&"%%%' OR ITEMNAME LIKE '%