Q:

Why won't my php function call with javascript button work?

I'm trying to call a php function which increments a database entry by 1 when a javascript button is clicked so the result is displayed on my page, the button, however, does nothing. Could you tell me what is causing the problem in the code below? 
I realize this is probably a noob question but I did my share of research and this is the furthest I got with my low level of knowledge (I'm only beginning to learn), thus I'll be most grateful for any hints on what I should correct or learn.
  <?php
$con=mysqli_connect("XXX","XXX","XXX","XXX");
?>

<?php
function addOne()
{
global $con;
mysqli_query($con,"UPDATE voting SET A=A+1");
 }

$result = mysqli_query($con,"SELECT * FROM voting");

while($row = mysqli_fetch_array($result))
  {
  echo $row['A'];
  }

mysqli_close($con);
?>

<script>
function increment()
{
  <?php addOne();?>;
}
</script>

<button onclick="increment()">VOTE</button>

A:

You need to use AJAX to do that.
Something like:
function increment(){
    $.ajax({
        url: "example.com/increment.php",
        cache: false,
        success: function(html){
            //
        }
    });
}

And then on the server side, in some PHP file such as increment.php, you can update your database. Note that this example uses jQuery.

