Alexhoward Posted March 17, 2008 Share Posted March 17, 2008 Hi guys, you lot have a been a real help in the past, and i'm sorry to ask so much with this post but i'm soo confused....??? i really want to add a star rating script to my site, and found one i really like. it's called starbox http://www.nickstakenburg.com/projects/starbox/ all the others i found done IP tracking to stop people voting more than once but i don't want that Problem is, he doesn't explain how to use it in PHP, or indeed how to put it on your page. I'm realativley new at this, and i assume it's something you should already know before you start... the idea is: members page - vote, change vote - saved in sql table, update previous vote Main page - average of members vote - static image Thanks in advance it will be a real help if someone can point me in the right direction, or get me started on some code Thankyou!! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 17, 2008 Share Posted March 17, 2008 why not write your own in 5 minutes? you need a few things 1) A table of stuff to be rated 2) A table of ratings 3) A criteria that limits the voting (for this example say a users table with UserID) So you have something to be rated the user inputs a value 1-5 pass it via get post ajax whatever floats your boat Then you: 1) Query the Ratings table for a vote for that UserID and ItemID 2a) If a vote exist update query to replace old vote with new 2b) Add vote if no vote exist Then to output results 1) Query for results based on AVG(Rating) from `Ratings` Where ItemID = $itemid 2) Output however you like. Thats the idea Quote Link to comment Share on other sites More sharing options...
Alexhoward Posted March 17, 2008 Author Share Posted March 17, 2008 nice sounds easy enough.... but how do i make them all nice little stars? did you look at the examples on that link...? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 17, 2008 Share Posted March 17, 2008 the stars are always the big problem the way I have done it is I make a table with 5 cells in it (for 0-5 rating) and each cell's background image is a star. The style of the cell is determined by the mysql AVG i.e <?php $avg = 4.567; $avg = round($avg,0); $i = 1; while($i <6){ echo "<td "; if($avg >= $avg){ echo "class=\"filled_star\"";} else{ echo "class=\"unfilled_star\";} echo "></td>"; $i++; } ?> Quote Link to comment Share on other sites More sharing options...
Alexhoward Posted March 17, 2008 Author Share Posted March 17, 2008 ah, good plan. so can you click on your stars to vote? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 17, 2008 Share Posted March 17, 2008 ah, good plan. so can you click on your stars to vote? Like I said u can pass the vote anyway you want http://www.thedealeruk.co.uk/ I wrote the Rate up/Down on that via Ajax Quote Link to comment Share on other sites More sharing options...
Alexhoward Posted March 17, 2008 Author Share Posted March 17, 2008 alright, cheers. you've given me an idea. i'll check back soon thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.