Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Count the number of times the search term
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Count the number of times the search term

 Post Reply Post Reply
Author
woodleyw View Drop Down
Newbie
Newbie
Avatar

Joined: 08 June 2003
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote woodleyw Quote  Post ReplyReply Direct Link To This Post Topic: Count the number of times the search term
    Posted: 08 June 2003 at 10:22pm
Here are the facts:

1). I built a site search engine and it is connected to a SQL database

My problem is that I would like to be able to count and display the number of times the search term appears in the results page.  I am seeking a script or function that would recognize the search term and then count the number of times it appears for each instance.

I am able to bold the search term everytime it appears in the results page but I can't figure out the code to establish the count.  I want the count to stop at "5".  I know that I must Dim variables and then assign the variable to the search term and then increment the count for everytime the search term appears but I just can't get the code to work.

Any assistance in solving this would be appreciated.

wlw
Back to Top
farrukh View Drop Down
Groupie
Groupie
Avatar

Joined: 10 May 2002
Location: Pakistan
Status: Offline
Points: 147
Post Options Post Options   Thanks (0) Thanks(0)   Quote farrukh Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2003 at 5:13am

Page = Request.QueryString("pg")
 If Page="" then
  Page = 1
Else
  Page = CInt(Page)
End if

Set conn = server.CreateObject("ADODB.Connection")
Set rs = server.CreateObject("ADODB.RecordSet")

conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("urdatabase.mdb")
conn.CursorLocation = 3 

if rs.recordcount = 0 then
 response.write "Record Doesn't Found"
else

 Rs.PageSize = 8            'Indicates Records Per Page
 Rs.AbsolutePage = Page    'Indicates The Page to Display

response.write "<tr><td colspan=2> You Search For <b>" & phone & "</b>. And We Found <b>" & rs.recordcount & "</b> results.</td></tr>"
response.write "<tr><td height=5> </td></tr>"

while (not rs.EOF And Rs.AbsolutePage = Page)
response.write "<tr><td> Name </td><td>" & StrCH(rs.fields(1)) & "</td></tr>"
response.write "<tr><td> Address </td><td>" & rs.fields(2) & "</td></tr>"

'-----------Function to bold the text-----------
Function StrCh(a)
 StrCh = Replace(a,phone,"<b>" & phone & "</b>")
End Function

'----------Table to Write Down the Pages-------------
'Rs.PageCount returns the number of pages.............
response.write "<table><td><center>Pages>> "

      For i = 1 to Rs.PageCount
  If i = Page then
   Response.Write "<font color=black>" & i & "</font>"
  Else
   Response.Write "&nbsp;<a href=phone_search.asp?pg="&i&"&query=" & sap & "&mysearch=" & phone & ">" & i & "</a>&nbsp;"
  End If
      Next
end if
%>
</table>

i have collected some nice avatars (37) and smileys (227) here you can download
http://www24.brinkster.com/webmastertool/download.html
Back to Top
woodleyw View Drop Down
Newbie
Newbie
Avatar

Joined: 08 June 2003
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote woodleyw Quote  Post ReplyReply Direct Link To This Post Posted: 10 June 2003 at 12:22pm

Thank you farrukh

I will try your code asap and let you know the results.

Thanks again!!

wlw

 

 

Back to Top
farrukh View Drop Down
Groupie
Groupie
Avatar

Joined: 10 May 2002
Location: Pakistan
Status: Offline
Points: 147
Post Options Post Options   Thanks (0) Thanks(0)   Quote farrukh Quote  Post ReplyReply Direct Link To This Post Posted: 10 June 2003 at 11:48pm
well i m waiting for your result if you have ne problem then i will be there....
i have collected some nice avatars (37) and smileys (227) here you can download
http://www24.brinkster.com/webmastertool/download.html
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.