How to do a "Top 10" thing

Discussion in 'PHP' started by twizzlers, Jun 30, 2008.

  1. #1
    not sure if this is a script thing, but how would u be able to do a
    "Top 10 most searched for" thing on a site?

    For example, on Yahoo's homepage, the 'Today's Top searches" box in the bottom right hand corner.

    How can you make it gather that data?

    Thanks in advance
     
    twizzlers, Jun 30, 2008 IP
  2. dannet

    dannet Well-Known Member

    Messages:
    864
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    153
    #2
    It depends on how is your site coded.

    You can store the searched keywords on a mysql table (search_id, search_keyword, search_hits), taking them from the search form and comparing the new inputs whit the stored data, if the input exist in the table, it update the search_hits field (search_hits = search_hits+1), if not, it create a new row in the table with the new keyword.

    In the front-end of the site, you can show the stored data ordering it using as parameter the search_hits field (example: order by search_hits desc limit 10), so it will show the most 10 search keywords. Its a few general explanation but its basically how you can do it with php and mysql.

    Good luck
     
    dannet, Jun 30, 2008 IP
  3. neuromante

    neuromante Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do you mean searchs from google? or is your site using its own search box.

    If first case, you would need to track the http referer of every incoming user and when coming from google, yahoo, etc, save to the db the keyword(s)
     
    neuromante, Jul 1, 2008 IP
  4. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    neuromante - I meant from my own site, but thanks :)
    dannet - I think I get the basic idea...but I'm new at PHP so will have to learn how to do the comparing thing :) thanks!
     
    twizzlers, Jul 1, 2008 IP