Top 10 List

Got a kewl website or have a website question? Hosting? Servers?
Post Reply
greasontim
Posts: 73
Joined: Tue Feb 15, 2011 3:14 pm

Top 10 List

Post by greasontim »

Wondering how to make a Top 10 List with a database
So if the link it clicked the most it shows up in the top 10 list
My host allows databases so it can be done through that.

If I have to do it by hand than meh.
But having the links clicked counted would be helpful still so I know what ones are the most clicked.

Overall plan for the website I'm working on is guides for games. (With login)
A list of any php game that people have made that use the site. (Links to the games as well of course)
Upload for user guides is up and working (somewhat)
Still have to go through and find errors with the site and that and fix them.
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Top 10 List

Post by Xaleph »

Create a new table called hitcounts. For each link clicked, check if a reference exists in the first table, if not, add it to the database. If it does, exist, increment the hit count by 1. Now, the big, BIG downside is that it doesn`t record where it`s origin is from. So, for proper hitlisting, I suggest you add a new table where you store the IP addresses, and link them to the corresponding links clicked. If done properly, you can safely delete that whole table every day ( unless you want your hits based on a different fixed time, in which case, it`s up to you ) .

So, table 1 "hitcounts":
("hitcounts_")id, link, hits ( positive, negative )

And table 2 "Addresses":
id, hitcounts_id, IP_address

EDIT: Oh yeah, to calculate the top10 is simply querying the best results on the first table. I know, it`s not really accurate if you want to populate what`s popular or top rated over a fixed rate, but if you implemented this, you can add them quite easy right? If not, we`re here :)
Post Reply

Return to “WebSite”