Page 1 of 1

rating function in php

Posted: Thu Nov 05, 2009 5:35 am
by bhanu
hi ,

how to code 5 start rating using php and mysql?

login member can only rate for items. one user can only rate item , one time only. we have to display total rating value in 5 starts.

Re: rating function in php

Posted: Thu Nov 05, 2009 3:10 pm
by Jonah Bron
Make a database that looks something like this:

Code: Select all

 
_____________________________
| ID | Rating | UserID | RatedItem |
|1   | 4        | 97284 | 89489     |
|2   | 2        | 3928   | 1048       |
|3   | 5        | 10094 | 183         |
 
Rating, is the rating the user provided. UserID is the identity of the user that provided the rating. RatedItem, is the object that the user rated.

If you want to prevent the user from rating an item more than once, just check for an entry that has the user's ID, and the RatedItem ID.