Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

139 users online



php rating script

php rating script

Currently viewing this thread: 1 (0 members and 1 guests)


flimbologic

flimbologic

Status: Offline!

php rating script

Hi all,
I am in need of a rating script for my site. What i mean is like a simple php script where people can rate each tutorial from say 1 to 5.
I.E. the rating in text then a button saying rate tutorial etc.

I have searched everywhere but i cant find a simple and easy to set-up script. Most of the good ones you have to pay $$!

Please help,
thanks.

___________________

http://www.zymic.com/images/linkzymic/88x312.gif

Sekkusu

Sekkusu

Programmer
Status: Offline!

Do you have your tutorials in a format where they are in a Database or at least have ID numbers for each?

If so, you can just have a little drop down, to select 1-5. You would just need two extra fields in your Tutorials database. These would be `avgrate` and `numrate`.

`avgrate` would be the average rating for the tutorial, such as average of 4.333.

`numrate` is the number of people who rated the tutorial.

For the code where someone votes on it, you will need a database to keep track of who has voted already (by Username, or IP)

Anyways, here is how the voting code would go:

`numrate` = 5
`avgrate` = 4.0

Do a check to see if they have already voted, if not:

Take `avgrate` times `numrate`. This will give you the sum of the numbers people have entered in. Then you add the user who voted's sum, lets say it is 5.0. So it is 5*4 = 20, then 20+5 = 25.
Add one to `numrate`, and then divide 25 (the new sum) by the new `numrate`. 25 / 6. That would give you the new rating, which you would update into the database under `avgrate`. Then their vote would be counted. Pretty simple concept, the only complex part would be if you didnt already have the tuts IDed or in a SQL database. It might take a little time to do the duplicate check, too, but that would just be a database that looks like this:

Database `whorated`
`username`
`tutorial`

Then when the person votes, it adds into that database, their username (can be replaced with IP if you want public rating) and which tutorial they rated. Then when they try to do it again, it finds a row with the same Username/tutorial and disallows them from rating again.

Oh well, its the outline of the code, it should be very easy to do as long as you know what you are doing.

Sekkusu

___________________

Swastika/Sauvastika: 1 2 3 4 5 6 7 8 9

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0067 seconds.