Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
  • 💬 Discuss
From the author of Retrieving Ratings

Retrieving Ratings

Once you have a few ratings in the system, to retrieve the average rating for an item, use this query (replacing X with the actual item ID):

SELECT ROUND(AVG(rating), 1) AS average FROM ratings WHERE item_id=X

That query will return a number rounded to one decimal point. You could run this query within the rating.php script in order to show the item’s average rating.

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus