tags:

views:

59

answers:

2

Looking for a good PHP & MySQL book that will show me how to build a rating system the correct way.

+1  A: 

If you're referring to merely displaying a X out of 5 stars, the simplest way is to have only 2 columns added to your table:

  1. average
  2. vote_count

The average is the X value (so you don't have to compute it every time) and when you want to have a vote affect the average just do:

$new_average = (($row['average'] * $row['vote_count']) + $_POST['new_vote']) / ($row['vote_count'] + 1);

and just store that new_average. It's going to be important to store a list of people who voted and what object they voted on, so people can't vote a second time. This is the simplest solution and adequate 95% of the time.

PS: If this doesn't answer your problem, keep in mind your question was short and vague.

TravisO
A: 

Note: There are no specific books about "how to cook this special application". You may only find general tutorials about CMS, OOP and Design Patterns.


How you create/design an application does not require any book, it just requires your ability to abstraction and creativity. Programming is just the "tool" through which you achieve your application.


If you are really interested in understanding rating sites, browse through the web an look at some opensource projects and try to understand their code.

For example:

daemonfire300