开发者

Star Rating System, Similar to Amazon

开发者 https://www.devze.com 2023-01-20 17:21 出处:网络
I\'m looking at adding a rating system to my site, similar to that seen on Amazon. Basically users can rate the product out of 5 stars.

I'm looking at adding a rating system to my site, similar to that seen on Amazon. Basically users can rate the product out of 5 stars.

I've been racking my brains to think of the calculation to get the average customer rating... but I can't think how to do it.

And looking at Amazon's system, I think their caculation may be incorrect. If you take this page for example:

ht开发者_StackOverflowtp://www.amazon.co.uk/exec/obidos...2521526-3543861

You can see that the average customer rating should actually be 5 stars as two people have chosen 5 whereas only one has chosen 4.

Any ideas??


You can calculate the average by taking the sum and dividing it by the number of values. In the case of ratings, it is the sum of all ratings divided by the number of ratings.

In the case you site, with ratings 5, 5 and 4, the average is (5+5+4)/3, which is 4.666..., and I'd guess they round to the nearest half yielding 4.5 out of 5.


why not try a jquery plugin?

http://orkans-tmp.22web.net/star_rating/index.html

0

精彩评论

暂无评论...
验证码 换一张
取 消