simple rating sytem

Ask about a PHP problem here.
Post Reply
mhakd14
Posts: 3
Joined: Mon Jul 09, 2012 11:05 am

simple rating sytem

Post by mhakd14 »

How can we use one and 0 only in ranking system ?

Also how we can build a star system like in Gmail ?

Thank you.
Last edited by jacek on Mon Jul 09, 2012 4:07 pm, edited 1 time in total.
Reason: Please learn to type.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: simple rating sytem

Post by Temor »

mhakd14 wrote:how can we use one and 0 only in ranking sysytem.
What?
mhakd14 wrote: And also how we can build a star system like in g mail
I'm guessing you're asking about a star rating system? Considering the title. If so:
You could post 5 ( or however many ) stars and give them a value when clicked, for example 1-5.
Star 1 = 1, Star 2 = 2, and so on.
You would then count each vote as well as the value of each vote and then do some basic math. Divide total value of votes with total count of votes.
Example: 257 Points / 150 votes = 1.7 average. This means we should highlight one full and seven tenth of a star, or just round it up and show two full stars.

The principles behind this is really simple. And there are tonnes of tutorials on how to create a 5-star rating system online.

If you're wondering about this:
Image
Clicking that star sets a boolean value in a database. Click it once for 1 ( true or on ) and again for 0 ( false or off ). Then a check is made to see if that item is starred ( if the Star is set to 1 ). Simple as that.
mhakd14 wrote: thank you
You're welcome!
mhakd14
Posts: 3
Joined: Mon Jul 09, 2012 11:05 am

Re: simple rating sytem

Post by mhakd14 »

Yes I mean the Gmail thing not the 5 star rating System. Temor just explain that Gmail thing bit more or please guide me for a good tutorial.

I am new to coding that's why.
Last edited by jacek on Mon Jul 09, 2012 3:17 pm, edited 1 time in total.
Reason: Please learn to type.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: simple rating sytem

Post by Temor »

It depends entirely on what you want to use it for. I'll give you an example of how it might look for email purposes like in Gmail.
The star has an " onclick " function attached to it, so that when the star is clicked it will set " Star " to " true ". They then check to see if " Star " is " true ". If it is, that means it's Starred and should be put in a separate inbox.
UPDATE `emails` SET `star` = 'true' WHERE `email_id` = 1
if($star = true){
echo "star is true".
}

Really, this would be very easy for you if you had some basic understanding of PHP coding, or coding in general.
I would suggest you start by watching some Basics tutorials and then work your way up to longer series of tutorials.
mhakd14
Posts: 3
Joined: Mon Jul 09, 2012 11:05 am

Re: simple rating sytem

Post by mhakd14 »

realy thank you.You are a great helper
Post Reply