Run PHP within Javascript Function

Asked

Viewed 98 times

0

I have the following function being called by onclick, the problem is that I can’t use Javascript variable in php, someone has an idea of how to do this function?

Function fila(id){

var idBanco = id;
console.log(variaveljs);

<?php
    $sql = "UPDATE `tabelaclientespos` SET `empresa` = '2' WHERE       
     `tabelaclientespos`.`Id` = idBanco";
    mysqli_query($conn,$sqlTempo);
?>

}

1 answer

-1

Isn’t it better to do it the other way around? Put the javascript function inside the tags and call it or not using PHP.

<?php
echo "<script>
          var idBanco = id;
          console.log(variaveljs);
          ".funcaophpaqui()."
          var x = ".$varphp."
      </script>";
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.