Jump to content

Starbox! Please help! i don't know where to start...


Alexhoward

Recommended Posts

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!!

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

 

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++;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.