从评级网站上的 MySQL 数据库计算排名和奖励
我有一个评级网站,人们可以在其中“授予”人们某些奖项:“最可爱”、“最棒”、“我喜欢你”、“最性感”、“最漂亮”、“最有趣”等,以及诸如“最蹩脚”之类的负面奖项, “最愚蠢”、“我恨你”等。
当有人使用我的费率页面添加新人时,它会存储在包含以下列的表中:来自、到、奖励。例如,如果我的用户 ID 是 5,而我授予“最可爱”奖的人是 10,那么它的存储方式如下:5,10,cutest。
现在的问题是,我想首先根据每个奖项给人们排名.. 就像获得最“可爱”奖项的人.. 然后,基于整体,就像获得最积极奖项的人。总体而言,如果人们有很多负面奖励,则应降低排名;如果有正面奖励,则应提高排名。
我不能(因为我的脚本的编码方式)有另一个计数表,例如:id,奖项,计数(可能是10,lamest,20,这意味着用户id 10,并且给出了20个最蹩脚的奖项)..所以我该如何计算?一种有效的方法,在 PHP 中。
多谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请考虑一下您所说的“不能(因为我的脚本的编码方式)”。我相信您会发现您可以做到这一点。每次,在插入新行之前,只需更新现有行(如果存在)...
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...