View Single Post
Old 07-14-2004, 01:28 PM   #6 (permalink)
Silvy
paranoid
 
Silvy's Avatar
 
Location: The Netherlands
Quote:
Originally posted by Fallon

When the voter sees the pic/story/etc, they vote on it, it gets added to the current rating then divide it by two. If you wanted to record the complete total, you'd need to probably make an array which would probably get kinda ugly.
If I see this correctly any vote would weigh the same as all previous votes combined...

I'd say store the total awarded points (the sum of all votes) in the 'rating' column and the total number of votes in the 'num_votes' column. When a user votes, add the value to 'rating', and add 1 to 'num_votes'. The average vote is then 'rating' / 'num_votes'.
This way there is no need for an array... (don't know how you figured that?)

If you want one vote per user (and thus a login type system) use the second, more elegant, solution by Fallon
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. "
- Murphy MacManus (Boondock Saints)
Silvy is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73