How to show average Vote

Discussion in 'PHP' started by CuBz, Nov 13, 2007.

  1. #1
    I am making a rating system where people can rate something on my website, but how do i do it so that it shows a total average rating between 1 and 10 after they have rated it, instead of them all added up?

    Cheers
     
    CuBz, Nov 13, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Add up all the ratings and divide it by how many total votes there have been

    floor() the result just to make sure you dont get any decimal values.
     
    tonybogs, Nov 13, 2007 IP
  3. indy2kro

    indy2kro Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you use a database to store the votes you can do something like this:

    SELECT AVG(vote) AS avg FROM votes
     
    indy2kro, Nov 13, 2007 IP
  4. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How thick am I lol

    I thought about dividing but i just couldnt think what to divide them by

    Thanks ;)
     
    CuBz, Nov 13, 2007 IP