User sumbitted top 5 and sort by popularity
Posted
by Bundy
on Stack Overflow
See other posts from Stack Overflow
or by Bundy
Published on 2010-03-18T10:41:47Z
Indexed on
2010/03/18
10:51 UTC
Read the original article
Hit count: 389
Hi,
Database setup (MySQL)
table: top_fives
id, uid, first, second, third, fourth, fifth, creation_date
1, 1, cheese, eggs, ham, bacon, ketchup, 2010-03-17
2, 2, mayonaise, cheese, ketchup, eggs, bacon, 2010-03-17
Users can submit their top 5 of a certain subject. Now I would like a summary of the top fives ordered by popularity.
Each column has it's own point value. column 'first' is rewarded 5 points, 'second' four points, 'third' three points, and so on...
So, in my example it should be something like this:
1 Cheese (9 points = 5 + 4 -> 1 time in 'first' column and 1 time in 'second' column)
2 Eggs (6 points)
3 Mayonaise (5 points)
4 Ketchup (4 points)
5 Bacon (3 points)
6 Ham (3 points)
What would be the easiest solution (PHP) for this kind of situation?
Thanks in advance
© Stack Overflow or respective owner