[PHP-DB] Average? From: Jeremy (sparhawk <email protected>)
Date: 11/15/00

I am making an area of the site where members can rate specific resources. They can add a comment for the rating. I am trying to make a seperate table that contains the average of all the ratings, so I can easily display the top-ranked articles.

Here is my table structure :

Table Comments

CommentID(key)
ArticleID
User
Comment
Rating

Table Rating

ArticleID
Article_Name
Rating

Right now, I am trying to find out how to get an average of all the ratings of the specified ArticleID, and then insert it into the Ratings Table.
I tried to use numrows to find what I should divide by, but if I fetch my results in an array, I can divide $rate["rating"] by 5....

What are the solutions to this?