Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,685 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,259 people online right now. Registration is fast and FREE... Join Now!




Rating thingie ...

 
Reply to this topicStart new topic

Rating thingie ..., Just need a little guidence / pointer where to start.

hallizh
post 5 Jun, 2008 - 03:32 PM
Post #1


New D.I.C Head

*
Joined: 9 Mar, 2008
Posts: 37


My Contributions


Hey there,

Im making a webpage with things(not really want to give up the purpose of the website just yet) that users should be able to rate with a Yes or a No, kinda like the youtube comments. When you click 'yes' the rating goes up by 1, when you click 'no' the rating goes down by one. When the number is negative its red but green when positive. If the number goes below some number(perhaps -10) it wont show anymore unless you click "Show".

The problem im having is that when a user clicks 'yes' for example, i want the number updated immediatly and make it so that he wont be able to vote again. I probably wont have a user system.

I dont need to fetch all the information from the database again do I?

Thanks for all the help, appreciate it now as always.
User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 5 Jun, 2008 - 04:00 PM
Post #2


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 474



Thanked 21 times

Dream Kudos: 350
My Contributions


Dream.in.code has a policy in which they request some part of a code in order for us to help you.

Anyway, onto business =P

no, you don't need to fetch the info... just add 1 or subtract one, then display it...

everything before that can be accomplished with if statements....

to make them NOT vote again, there's a few ways to do it....
1. log their IP, put it into the database, and check for that IP everytime someone votes
2. use cookies/sessions to check that they've already voted
User is offlineProfile CardPM

Go to the top of the page

hallizh
post 5 Jun, 2008 - 04:18 PM
Post #3


New D.I.C Head

*
Joined: 9 Mar, 2008
Posts: 37


My Contributions


Yeah but, the data is displayed, then you vote. And then i want the updated number to be shown. IE.

This is something amazing!! : 13 icon_up.gif icon_down.gif
This is something mediaocre: 0 icon_up.gif icon_down.gif
This is something awfull ... ! : -19 icon_up.gif icon_down.gif

This is shown. When you click a thumb, then you vote en then i want the number to increase, just as he clicks. Hope you understand me.

New to php as you can see tongue.gif smile.gif


EDIT: Removed a code line, had an error but fixed it myself.

This post has been edited by hallizh: 5 Jun, 2008 - 04:27 PM
User is offlineProfile CardPM

Go to the top of the page

capty99
post 5 Jun, 2008 - 04:44 PM
Post #4


the real kya

Group Icon
Joined: 26 Apr, 2001
Posts: 9,137



Thanked 15 times

Dream Kudos: 550
My Contributions


I'm sure you need some javascript.

The php is simple enough, you just pull a ranking from the db (13 for this example) then when they click it send the db that original variable + 1 (so 14) and then use js to change the number displayed.
User is offlineProfile CardPM

Go to the top of the page

hallizh
post 5 Jun, 2008 - 04:48 PM
Post #5


New D.I.C Head

*
Joined: 9 Mar, 2008
Posts: 37


My Contributions


Okay will do. Thanks alot. smile.gif
User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 5 Jun, 2008 - 06:08 PM
Post #6


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 474



Thanked 21 times

Dream Kudos: 350
My Contributions


yup, what capty said.... you'd have to add an onclick element to the thumbs up/down, and create a function in JS to add or subtract one.... I would (however), NOT use JS to put it into the database, as someone could change the value to add or subtract more then it is supposed to....

with PHP, it's more secure, as it can't be changed...
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 6 Jun, 2008 - 08:43 AM
Post #7


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 596



Thanked 22 times

Dream Kudos: 750
My Contributions


You might be able to write an AJAX script that solves both your problems. It could post back to the database, write the new value, and then display the new value, all without reloading the page. Read some AJAX tutorials if that sounds ideal.
User is offlineProfile CardPM

Go to the top of the page

hallizh
post 10 Sep, 2008 - 06:08 PM
Post #8


New D.I.C Head

*
Joined: 9 Mar, 2008
Posts: 37


My Contributions


Thank you guys, helpfull as always smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:11AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month