如何建立简单的评论和五星级评级系统? [英] How to build simple reviewing and 5-star rating system?

查看:131
本文介绍了如何建立简单的评论和五星级评级系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对网络技术非常陌生,这基本上是我的团队正在研究的学期项目.我们正在一个食品评论网站上.

I'm very new to web technologies and this is basically for a term project that my team is working on. We are working on a food review site.

截至目前,我还不确定如何实施简单的5星级评分系统.我应该使用像PHP这样的服务器端语言还是像Javascript(带有JQuery)的客户端语言.环顾四周,看来JQuery更适合于此吗?还是两者结合?

As of now, I'm not quite sure how to implement a simple 5-star rating system. Am I supposed to use a server-side language like PHP or a client-side one like Javascript (w/ JQuery). Looking around it seems that JQuery is more suitable for this? Or would it be a combination of both?

就功能而言,我正在寻找的是:

What I'm looking for as far as functionality goes is:

  • 当鼠标悬停时,星星会亮起
  • 在以下情况下不必重新加载页面 单击一个星星(不是必需的)
  • 在 星星
  • 评级必须存储在MySQL数据库中的某个位置(这是个好主意吗?)
  • Stars light up when mouse hovers
  • Page doesn't have to be reloaded when a star is clicked (not really needed)
  • Some sort of average shown beside the stars
  • Rating has to be stored somewhere in a MySQL database (Is this a good idea?)

如果这个问题听起来模棱两可和愚蠢,我真的很抱歉,我对如何实现这一点没有太多的了解,并且我已经尝试了一下.如果您对此有任何疑问,请告诉我.

I really apologize if the question sounds vague and stupid, I don't have much of a clue on how to implement this and I've tried googling around. If you have any questions about it please let me know.

非常感谢您.

推荐答案

当鼠标悬停时,星星会亮起
网上有一个精妙的教程,用于设计5星级评分系统: http://rog.ie/blog/css-star-rater .它完全是CSS,因此不需要Javascripting.

Stars light up when mouse hovers
There's a brilliant tutorial on the web for designing a 5 star rating system: http://rog.ie/blog/css-star-rater. It's purely CSS so no need for Javascripting.

点击星标时不必重新加载页面(并非真正需要)
Ajax是您的朋友,我要做的是拥有一个<a class="one_star" href="javascript: submitRating(1, 5)">,其中<a>代表一颗星星,而submitRating()函数使用Ajax将我的评级(1/5)传输到服务器,服务器存储评分(并分配给出评分的用户),然后重新计算新的平均评分,然后以JSON格式提交结果.

Page doesn't have to be reloaded when a star is clicked (not really needed)
Ajax is your friend, what I did was to have a <a class="one_star" href="javascript: submitRating(1, 5)"> where <a> represented a star and the submitRating() function used Ajax to transmit my rating (1/5) to the server, the server stores the rating (and assigns the user that gave the rating) and recalculates the new average rating and submit the results back in JSON format.

恒星旁边显示的某种平均值
容易.编写一个基于产品ID的SQL脚本,该脚本获取平均评分的 sum (即1/5 + 2/5 + 4/5等),然后将其(sum)除以收视率总和乘以100.将值返回到服务器,再从服务器返回到客户端.

Some sort of average shown beside the stars
Easy. Write a SQL script that, based on the product id, takes the sum of the average rating (i.e. 1/5 + 2/5 + 4/5, etc), divide it(sum) by the total amount of ratings and multiplies it by 100. Return the value back to the server, and from the server back to the client.

评级必须存储在MySQL数据库中的某个位置(这是个好主意吗?)
我正在为此使用MySQL,它的工作原理很吸引人.任何DB系统都可以.

Rating has to be stored somewhere in a MySQL database (Is this a good idea?)
I am using MySQL for this and it works like a charm....Any DB systems is fine.

这篇关于如何建立简单的评论和五星级评级系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆