Print Page | Close Window

Current top search terms

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7764
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Current top search terms
Posted By: WebDever
Subject: Current top search terms
Date Posted: 01 December 2003 at 9:43am

Hi ALL,

Can somebody help me, i've set up a search app, going through a database but i would like to display the 'Current top search terms' on the frontpage how would i do this?

Please, please, please can you help me

Thank you for help




Replies:
Posted By: Boecky
Date Posted: 01 December 2003 at 1:58pm
hmm...count the clicks of the links that found via the search and display the top 5 of most clicked items. Is this what you mean?


Posted By: pmormr
Date Posted: 01 December 2003 at 4:54pm

store the search terms that were searched in a database. make sure you check for doubles... if the term was already searched then increment a field in the database (something like "timessearched"). then just pull the top five searched terms on your homepage

 



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: WebDever
Date Posted: 02 December 2003 at 2:25am

Sorry, i have to ask.

How do you do that exactly? If it's not too much trouble

Thanks for your help



Posted By: pmormr
Date Posted: 02 December 2003 at 1:35pm

it's no problem at all. i'll write a quick example... i can't guarentee that it'll have zero errors, but it'll give u the idea

<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.provider = "Microsoft.Jet.OLEDB.4.0" 'access 2000 database
conn.open "c:\mydatabase.mdb" 'database path

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset") 'create a recordset
rs.open "SELECT * FROM [tblCount] WHERE searchterm = '" & Request.QueryString("searchterm") & "';", conn 'open up a recordset

'If it found a record with the search term then that means
'it's already been searched, if it didn't, it's a new term
If rs.EOF and rs.BOF then
   'it's a new term, add it to the database
   conn.execute("INSERT INTO tblCount (term, counted) VALUES ('" & Request.QueryString("searchterm") & "', '1');")
Else
   'it's already been searched
   rs.movefirst
   Dim varCount
   varCount = rs.fields("counted")
   varCount = varCount + 1
   conn.execute("UPDATE tblCount SET counted = '" & varCount & "' WHERE term = '" & Request.QueryString("searchterm") & "';")
End If

'clean up
Set rs = NOTHING
conn.close
Set conn = NOTHING
%>

change the necessary things in the script. put this in your search script (as long as your search term is under "searchterm" in the querystring... if not then change it)

on your homepage, put something like this where you want to display your top 5 results...

Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.provider = "Microsoft.Jet.OLEDB.4.0"
conn.open "c:\mydatabase.mdb"

Dim rs
Set rs = Server.CreateObject("ADODB.recordset")
rs.open "SELECT * FROM tblCount ORDER BY counted DESC", conn

Dim i
i = 5

While i > 0
   Response.Write rs.fields("term")
   Response.Write "<br>"
   i = i - 1
   rs.movenext
Wend

'clean up
conn.close
Set conn = NOTHING
Set rs = NOTHING
%>



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: WebDever
Date Posted: 03 December 2003 at 4:42am

Are you top end developer or something? you must be a bloody genius!!!

Thanks for your help mate, you really have helped me out

Cheers,



Posted By: pmormr
Date Posted: 03 December 2003 at 1:16pm
any time

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net