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.
rating function in php
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: rating function in php
Make a database that looks something like this:
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.
Code: Select all
_____________________________
| ID | Rating | UserID | RatedItem |
|1 | 4 | 97284 | 89489 |
|2 | 2 | 3928 | 1048 |
|3 | 5 | 10094 | 183 |
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.