0

我需要知道如何为网站制作评级脚本。我有一个表格,可以向MySQL提交 10 分的评分。您将如何获得从MySQL列中显示的平均评分?

--- 使用 PHP 和 MySQL

4

2 回答 2

2

最好的方法是存储 2 列 - rate_count 和 rate_total。然后,当您获得新评级时,您只需发布如下更新:

update rating_table set rate_count = rate_count + 1, rate_total = rate_total + $rating where id = $id

然后得到你检索rate_count和rate_total的平均值。只要 rate_count > 0,rate_total/rate_count 会给你你的平均评分。

于 2010-04-15T23:49:38.903 回答
0

看看这篇文章和代码http://www.amitpatil.me/youtube-like-rating-script-jquery-php/

于 2011-11-25T04:32:11.303 回答