Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    57
    Thanks
    15
    Thanked 1 Time in 1 Post

    Question Looking for simple yes/no vote script

    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
    Newbie at most things ...Hey we all gotta start somewhere right :)

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    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

    PHP Code:
    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.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •