Page 1 of 1

Need help with a voting script

Posted: Thu Apr 17, 2008 12:34 am
by Kosh
Hello,

Well, I'm completely new to programming, though I have a few years experience in html and graphic design, and I've tried reading some tutorials about php, mysql, etc so I can make a voting script for a site. I haven't had any luck though, so I was wondering if someone here can help me write it and set it up. The thing is, the website it will be for is currently entirely static content (just an html website with some reviews on it, all normal text), so I haven't set up any databases for it or anything. All I need the script to do is display the text "Do you agree with this review? |_| Yes" and the number of votes on each review page, then display the top five agreed with reviews on the main page numbered 1 - 5 and showing band name - album name and linked to the page the review is on. I've tried to do it and read tutorials but I just can't seem to get it to work. Anyway, I was wondering if someone would be willing to help me with this seemingly simple script, I would really appreciate it. Thanks in advance for any help! :)

PS, this is an example of what I want on the review page, the voting box toward the bottom of the page: http://www.reviewstream.com/reviews/?p=33807

Re: Need help with a voting script

Posted: Thu Apr 17, 2008 5:58 am
by onion2k
"seemingly simple script" ... seemingly is right. Voting on websites is actually really complicated to do properly.

On a basic level though what you need is a counter to count the number of yes votes for each review. So you'll need a database table with a reference to the review (a number, or a code, or a url), and an integer that counts the number of votes. When a user submits a vote you'll need to update the number by adding 1 to it.

The logic of this process is...

User reads the review
User clicks a button that sends your script a reference to the review
Your script recieves a vote (via GET or POST)
Your script updates the database using the reference the user sent to know which counter to add 1 to.

Then, when you want to find the top 5 reviews, you just have to select the 5 from the database with the highest numbers.