Does anyone knows how to do a rating system. In fact, I have already build it but I don't know how to merge it with the articles that have to rated. Each article should have a unique rate. It's like on youtube. If any one knows how to do it or can give a few advice. I'll be grateful.thanks in advance.
http://www.islandinfo.mu
rating star
Moderator: General Moderators
Re: rating star
You need a database table with the article_id, total_votes, total_points.
Increment total_votes each time a vote is cast for that article, increment total_points by the rating the article received.
Do some math to get the rating.
You could do more and add in user ids or usernames to ensure each user only votes once.
Increment total_votes each time a vote is cast for that article, increment total_points by the rating the article received.
Do some math to get the rating.
You could do more and add in user ids or usernames to ensure each user only votes once.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: rating star
I'm actually in the middle of implementing this for my own website at the moment. ^_^
After setting up the database the way that ~scottayy has shown:
After setting up the database the way that ~scottayy has shown:
Code: Select all
$rating = 0;
$decimalPlaces = 2;
if ($data->totalVotes != 0) {
$rating = number_format($data->totalPoints / $data->totalVotes, $decimalPlaces);
}Re: rating star
I agree with the other 2 responders, but since you included the word "star" in your Subject, I'm assuming you are interested in the row of stars with some in gold, or something, as the display. Take a look at my site http://poatree.info and click on the Go To The Poems button. Is this what you're after? If it is, I'll be glad to send you the code for maintaining and displaying the ratings.abhikerl wrote:Does anyone knows how to do a rating system. In fact, I have already build it but I don't know how to merge it with the articles that have to rated. Each article should have a unique rate. It's like on youtube. If any one knows how to do it or can give a few advice. I'll be grateful.thanks in advance.
http://www.islandinfo.mu