Rating System in PHP and MySQL

前端 未结 3 1600
花落未央
花落未央 2021-01-21 15:00

If we look at the stackoverflow website we have votes. But the question is what is the bestway to store who has voted and who has not. Lets also simplify this even more and say

3条回答
  •  佛祖请我去吃肉
    2021-01-21 15:23

    A new table:

    Article ID | User ID | Rating

    Where Article ID and User ID make up the composite key, and rating would be 1, indicating upvote, -1 for a downvote and 0 for a removed vote (or just remove the row).

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题