Results 1 to 7 of 7
  1. #1

    Hi Help With Rating System

    Hello
    I have a rating system. These are the values i store for each rating: Number of Votes, Previous Rating, Current Select Rating.
    Which is the best way (formula) to calculate average rating??
    Thanks for your help!

  2. #2
    Join Date
    Mar 2004
    Location
    Cleveland, Ohio
    Posts
    182
    Total Number Possible / Total Number users have voted times 100 gives a percentage if thats what your looking for.
    SepCity.com - Content Management / Portal Software Solutions
    Host on our network or buy our software to host on your own server

  3. #3
    Join Date
    Dec 2007
    Location
    Lebanon
    Posts
    413
    yes that is the formula for all ratings I guess

  4. #4
    Join Date
    Feb 2003
    Location
    L.A. C.A.
    Posts
    335
    If its MySQL, MySQL does have an AVG() function for columns :]
    WLKNS.co - A collection of my programmer thoughts

  5. #5
    If it was me I would have created a special table for votes like that:
    vote_id,item_voted,vote,date

    And then do a select query for all the votes for a specific voted (the actual item voted).
    Then when you have all the rows, calculate the average of all the "vote" field in all rows.
    That way you can then manage your votes and delete/edit them if necessary.

  6. #6
    Join Date
    Dec 2007
    Location
    Lebanon
    Posts
    413
    Quote Originally Posted by shreder View Post
    If it was me I would have created a special table for votes like that:
    vote_id,item_voted,vote,date

    And then do a select query for all the votes for a specific voted (the actual item voted).
    Then when you have all the rows, calculate the average of all the "vote" field in all rows.
    That way you can then manage your votes and delete/edit them if necessary.
    logically speaking that is the best way to be done!

  7. #7
    Join Date
    May 2008
    Location
    Rutherford, NJ
    Posts
    68
    assuming number of votes includes the one stored as current select:

    ((previousrating * (numbervotes-1)) + selectedrating) / (numbervotes)

    if the number of votes does not include the current, just switch it to:

    ((previousrating * numbervotes) + selectedrating) / (numbervotes+1)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •