Calculating rank and awards from MySQL database on a rating website
I have a rating website where people can "award" people certain awards: "Cutest", "Awesomest", "I Like you", "Hottest", "Prettiest", "Funniest", etc and negative ones like "Lamest", "Stupidest", "I Hate you", etc.
When someone adds a new person using my rate page, it is stored in a table with these columns: from,to,award. So for example if my userid is 5, and the person I am giving the award "cutest" is 10, then it is stored like this: 5,10,cutest.
Now the thing is, I want to give people ranks, firstly, based on each award.. Like the person who got the most "cutest" awards.. and then, based overall, like the person who got the most positive awards. For the overall, people should downrank if they have many negative awards, and uprank for positive 开发者_开发问答awards.
I cannot (because of the way my script is coded) have another table for counts like: id,award,count (which could be 10,lamest,20, which would mean user id 10, and 20 lamest awards given).. So how do I calculate it? an efficient way, in PHP.
Thanks a lot.
Please think over what you said regarding "cannot (because of the way my script is coded)". I'm sure you'll find out you can do just that. Just each time, before inserting a new line, just update the existing line, if such exists...
精彩评论