[RESOLVED] Finding 10 most popular entries in a table?
I'd like to add a feature to my site whereby whenever someone clicks on an item it will add that items tags to a table. Then, I can look into this table and find out the top 10 entries. Make sense?
The bit I'm stuck on is how to find just the top 10 UNIQUE entries rather than just the top 10 entries.. How can I find it out?
Thanks;)
Re: Finding 10 most popular entries in a table?
What is your table structure like?
Re: Finding 10 most popular entries in a table?
table Tags
tagID - int
tagName - string
That's it. So when an item is clicked, I just get it's tags and add each one seperately to the table..
Re: Finding 10 most popular entries in a table?
Why not:
tagID
tagName
tagCount
Then, when you click an item, check to see if it is present in the table; if it is, increment its count field; if it's not, add it.
Or even better, add the tags when you add the item, so you don't have to check whether it exists or not.
Re: Finding 10 most popular entries in a table?
Ah, much better idea. Thanks ;)