Hey guys, I'm trying to start a yes/no vote div which, when clicked, increments MySQL entry either way. I've seen several examples of how to do this type of thing online, but can't seem to grasp this process on my current layout. I'll show a little as possible to not overload you.

js

function vote(vote, item)
{
    $("#ajaxDiv").eq(0).load("pole.php?choice="+vote+"&item=" + item);
}

pole.php

<?php
    $con1 = mysql_connect(xxxx) or die(mysql_error());
    mysql_select_db(xxxx, $con1) or die(mysql_error());

    $item = stripslashes($_GET['item']);

    if ($_GET['choice']=="yes")
    {
        $update_query="UPDATE table SET yes = yes + 1 WHERE id='$item'";
        mysql_query($update_query, $con1);
    }
    else if ($_GET['choice']=="no")
    {
        $update_query="UPDATE table SET no = no + 1 WHERE id='$item'";
        mysql_query($update_query, $con1);
    }   

    $result = mysql_query("SELECT * FROM table ORDER BY id DESC");
    $row = mysql_fetch_array($result);
    ?>
    <p><? echo $row['question'] ?></p>
    <p><img src='img/layout/vote.jpg' width='250' height='71' alt='Vote Now!' usemap='#voteMap' /></p>";
    <map name="voteMap">
        <area shape="rect" coords="19,9,114,40" href="#" onclick="vote('yes', <? echo $row['id'] ?>)" alt="Yes">
        <area shape="rect" coords="133,9,229,40" href="#" onclick="vote('no', <? echo $row['id'] ?>)" alt="No">
    </map>

HTML

<div id="ajaxDiv">
    //similar code to pole.php minus php update calls
</div>

if I run it all together as is, it simply updates the "ajaxDiv" with the pole.php content not updated, however, If I run pole.php with the correct parameters (eg: pole.php?choice=yes&amp;item=3), it updates the database correctly.

EDIT: appears I was wrong on the PHP update, checking into that now

Simple overlook as always, Sorry for the garbage post. Looks like I should have used an & symbol instead of &amp; in the js. Maybe this can help someone else with the basic idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.