...

View Full Version : Looking for simple yes/no vote script



buggy
01-25-2010, 03:49 AM
Been Googling all evening but can find anything relevant to what I need ...

Ok Im coding a script where visitor searches for item and obvoiusly is given a list of results well Im after a simple Yes / No vote script where visitors can vote to say if indervidual items they found work or not ..

I'm thinking a simple update in a database field so with each click the number stored goes up of which I could echo:

Working? Yes: 28 No: 12
but don't know where to start ...any help is appreciated

As always thank you in advance :)

masterofollies
01-25-2010, 05:05 AM
1. Make a database table called like "items".

2. Next add 4 fields. ID, NAME, YES, NO. Default 0 for YES and NO

3. Make the ID an auto increment

4. Make a new insert for each item.

5. When they click yes and no, do a query to update the database for that item, and add +1 to what they clicked. Like this


function vote($id) {
//Say they clicked yes
if ($_POST['submit']) {
mysql_query("UPDATE items SET yes=yes+1 WHERE id='$id'");
echo 'Thanks for voting!';
}

Set it up where you can pull the id of the items to put in the WHERE area of the query. It will tell it which product to update it for.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum