MDanz Posted February 15, 2010 Share Posted February 15, 2010 how would i do this? e.g. "cars" was the most searched term on my website.. Quote Link to comment https://forums.phpfreaks.com/topic/192187-tags-most-popular-searched-terms/ Share on other sites More sharing options...
sKunKbad Posted February 16, 2010 Share Posted February 16, 2010 Every time somebody searches, you add that to a database table, perhaps with other info like the IP address. If you want to know what the most popular database searches are, you query the database to return the column, use some function like trim() on each row, also converting all chars to lowercase, and then you'll use a simple function to count all occurrences of each search term or phrase. Put each term or phrase in an array with it's count, and then sort the array by count. Pick off the top 5, 10, or whatever. This might be a lot of work.... so you might cache this and only run it once every half hour or something. Also, since you have a top 5 or 10, you might consider deleting rows that don't seem to have a chance to compete, if you know what I mean. You could probably tweak this to perfection, or with minimal work at least get something usable. Quote Link to comment https://forums.phpfreaks.com/topic/192187-tags-most-popular-searched-terms/#findComment-1012969 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.