Page 1 of 1
Rating System
Posted: Thu Sep 29, 2005 7:02 am
by alexmaster_2004
HI
i'm try to add a rating section to my web site.
i want to make it a pro one just like what you can find here
download.com i like their way.
also here is fine
windows market place
i had tried to do it myself but i didn't come to anything.
so i hope if you can help me.
Thanks in advance
Posted: Thu Sep 29, 2005 7:12 am
by Grim...
Store the number of votes made, and the total of all the ratings.
So, if someone gave 'mycode' a 3, someone else gave it a 4, and someone else gave it a 1, it would have 3 total votes and a rating of 8.
Store these numbers in a database, and when you need to pull out the average rating, divide 8 (total of the votes) by 3 (total number of votes).
Yaaargh
Posted: Thu Sep 29, 2005 7:16 am
by Grim...
If you want stars, have an image for 1 out of 5, 2 out of 5 ... 5 out of 5. Call them star_1.gif ... star_5.gif.
Now do a ceil on your average score, and call the correct gif, maybe:
Code: Select all
$stars = ceil($votetotal / $totalnumberofvotesvotes);
print "<img src=\"star_".$stars.".gif\" />";
Yarrrrrgh
Posted: Thu Sep 29, 2005 7:22 am
by alexmaster_2004
Hi
first thanks for ur reply
but i still want to know how the user will enter his rate.
as you see in download.com the user hover the mouse over the stars
and then choose his rating.i want to know how to do this.
all what i want is enable the user to choose the rate by fillup the stars
Thanks
Posted: Thu Sep 29, 2005 7:32 am
by shiznatix
im not registered with download.com so i don't know exactally how they do it. just have each star as a link, if there are 5 stars then the 1st star has a get var of being 1, 2nd star would be 2 and so on. then just use the get var on the page that updates the db to find out which ranking they chose
Posted: Thu Sep 29, 2005 7:44 am
by Grim...
Download.com uses javascript to change the colour of the stars depending on where the user has his mouse over the image - Google for 'onmouseover image' and you'll find a some good starts on how it's done.