At 1/18/08 12:08 AM, Snubby wrote:
so I would need a table with every member and every game? like i could stick every thing i want to rate as a new field into my members table, but then it could end up having hundreds of fields. and vice versa, i could have each user as a feild in each content table, but then im still looking at hundreds of fields. is that the only way of doing it?
you have a users table, and a games table, I'm assuming. So you make a third table- user_game_votes
whenever a user votes on something, add an entry to the user_game_vote table. It will basically consist of four values- id (unique auto_increment), user id, game id, and vote(whatever they rated the game).
before you let someone vote on the game, select count from user_game_vote where userid = their id and game id = the current game's id. If a row is returned then they have already voted, so they can't. Otherwise, add the new row
to calculate score for a game, select all rows from the user_game_vote table where game id= the current game. Add them up an divide by the total rows for your average, and there you go
that's the basic idea