I want to access a javascript variable inside a php query
function myFunction2(){
    Total=parseInt(point2)
    <?php
    $con->query("UPDATE eventlist SET P2 = $this.Total WHERE Eid=$PID");           
    ?>
  }
I want the query to set p2=value of total
I understand that php is a serverside script and I cant do this like this. What is an alternative to this.?
EDIT
ok i got this on the JS side
function myFunction2(){
       var Total = parseInt(point1)+parseInt(point2);
         $.ajax({ url: 'ajax.php',
         data: {'total' : Total},
         type: 'post',
         dataType:'json',
         success: function(output) {
                      alert(output);
                  },
          error: function(request, status, error){
            alert("Error");
  }
and if i put
echo $_POST['total']
in ajax.php i get an alert with the value passed. So i think the value is being passed properly. But what i need to do is a Mysql Query.
$con->query("UPDATE eventlist SET P2 = $_POST['total']; WHERE Eid=1");  
Something like this. How do i do this
 
     
    