_tina_ Posted September 16, 2009 Share Posted September 16, 2009 Hi, I need to display the most popular / most searched for terms. Do you know how to go about this? I hope my question isn't too vague. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/174469-php-popular-search/ Share on other sites More sharing options...
JonnoTheDev Posted September 16, 2009 Share Posted September 16, 2009 Yes it is a bit vague, however if you are recording searchterms then you should record a count against the term i.e. searchterms ========= id (INT) term (VC 255) searchcount (INT) Everytime a search is performed check if the term exists in the table, if so update the count, else insert a new term. Then you can easily run a query to get your top searches i.e. SELECT term FROM searchterms ORDER BY searchcount DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/174469-php-popular-search/#findComment-919546 Share on other sites More sharing options...
_tina_ Posted September 16, 2009 Author Share Posted September 16, 2009 Hi Neil, Thanks for the reply. So I will need to record every search term? Is this the only way to go about doing this? Thanks again Yes it is a bit vague, however if you are recording searchterms then you should record a count against the term i.e. searchterms ========= id (INT) term (VC 255) searchcount (INT) Everytime a search is performed check if the term exists in the table, if so update the count, else insert a new term. Then you can easily run a query to get your top searches i.e. SELECT term FROM searchterms ORDER BY searchcount DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/174469-php-popular-search/#findComment-919561 Share on other sites More sharing options...
JonnoTheDev Posted September 16, 2009 Share Posted September 16, 2009 The only way to know what the most popular searches are is to have data that you can query on. It is up to you how you store the data. Quote Link to comment https://forums.phpfreaks.com/topic/174469-php-popular-search/#findComment-919582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.