Jump to content

Star Rating Script.... anyone know one that can do this...?


Alexhoward

Recommended Posts

Hi guys,

 

Loving this site,

 

as a newbie, who doesn't know what he's really doing, i'm made some pretty good progress.

 

Mainly down to you lot! and a bit of google :D

 

So what would i like to do?

 

1) members rate there links (pulled from whatever they've chosen from the main page) using a 5/10 star rating system

 

2) the content on the main page then displays the average of the users votes under each link.

 

 

some main points:

 

1.  I want the members to be able to change their rating, and just display their vote on their page.

 

(incase they really like the link, then one day it all goes wrong, and they hate it)

 

2.  on the main page to display the average of all the votes under each link, as a static vote

 

3.  Only members can vote (from their page)

 

Does this make sense...?

 

Thanks in advance

 

 

 

 

 

 

Link to comment
Share on other sites

Set up a `ratings` table (or something named similar) that will store all the ratings in it.  Set the table structure so it's something like this:

 

id

link_id

user_id

rating

 

id will be the unique identifier of the rating

link_id is the id number of the link which was rated

user_id is the id number of the user who voted

rating is the number which they voted (1-10)

 

With this structure you'll be able to get a total number of votes, averages, and because of the user_id field you'll be able to allow the user to edit their own votes (show a list of votes where the user_id field = their id).  It can be quite a complicated system, but this is a basic outline and can get you going.

Link to comment
Share on other sites

Nice one,

 

that seems obvious enough.

 

that table has the potential of getting enomous thou...

 

is that going to slow down my site?

 

also i take it that when i display the average on the main page, i just pull an average of the votes where the link equals the linkid?

Link to comment
Share on other sites

I wud skip the id

 

and have it

link_id

user_id

rating

 

with the link_id and user_id as primary keys.

 

it does have the potential of getting huge, however sql is a database, driven for large amounts of data.

 

the average can be done thru mysql as well

 

SELECT link_id,AVG(rating) as avg_rating FROM ratings GROUP BY link_id

Link to comment
Share on other sites

Cheers Guys,

 

Yea will just have it:

 

Link, username, rating

 

and cheers that link looks like the kind of thing i'm after

 

however, when the user changes there vote, i want it to replace to vote they already made,

 

assume that's just a little change in the code... or not so little

 

haven't got time to look at it all now

 

Thanks :D

 

 

Link to comment
Share on other sites

If you're wanting to update their vote, just update the row where the user_id = their id, and the link_id = whichever link they're editing, something like this:

 

UPDATE `ratings` SET `rating` = rating + 1 WHERE `user_id` = '{$user_id}' AND `link_id` = '{$link_id}'

 

Of course you'll need to get the values of $user_id (probably from a session) and $link_id (probably from the update form).

Link to comment
Share on other sites

Hi guys,

 

Thanks for the links,

 

What i'd really like is a star graphic script like http://js-kit.com/ which scepanmali suggested,

 

but one that's on my own site, using my database, rather than some other website.

 

I'm finding this part really dificult.

 

The other parts of my site, have been hard but i've been able to get through it,

 

with this however, i'm really stumped, don;t even really know where to start.

 

Does anyone know a good tutorial for a 5 star rating script...?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.