Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 767859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:05:29+00:00 2026-05-14T18:05:29+00:00

I have asked this once before but i didnt get a very clear answer.

  • 0

I have asked this once before but i didnt get a very clear answer.

I need to know how to make a rating script for a site. I have a form that submits a rating out of ten to mysql. How would you get the average rating to be displayed from the mysql column using php?

One person suggested having two tables; one for all the ratings, and one for the average rating of each page. Is there a simpler method than this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:05:30+00:00Added an answer on May 14, 2026 at 6:05 pm

    You will want to store the rating for each time a page is ratd. because if you just store the average rating in one column, such as

    ratings (page_id, average_rating)
    

    It is not easy to determine:

    1. How many users rated
    2. Distribution of the ratings (how many voted 10, for example)

    And you cannot allow users to change their rating, because everything has been flatten into one row. You can do without the second table if you use the average function in MYSQL

    $result = mysql_query("SELECT AVG(rating) FROM ratings GROUP BY page_id WHERE page_id = '$pageid'");
    $rating_for_page = mysql_fetch_row($result);
    $rating = $rating_for_page[0];
    

    Notice that I am assuming each rating is stored as a seperate row

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know questions of this kind have been asked before, but my situation differs
This question has been asked more than once before, but I have not found
This question has been asked before ( link ) but I have slightly different
This question seems to have been asked before, but I feel like my situation
I know this has been asked here before but my conditions are a little
I know this question has been asked and answered before, but none of the
Similar questions to this one have been asked but none seem to address my
I have asked a similar question before, but I didn't have a firm grasp
similar questions have been asked before but I cant find an exact match to
I asked how to do this before but it seems I needed to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.