-3

I want to take my variable in php, and put in a variable in javascript there is my code in php :

$SQL=$pdo->query("SELECT SUM(nbdeces) as totalnbdeces FROM nombre_deces");
$data = $SQL->fetch();
$sommeanswered = $data['totalnbdeces'];

I want to stock the variable "$sommeanswered" in a variable javascript

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    It would be useful to know what else there was in this script file and where abouts in the script this code lived – RiggsFolly Jun 14 '19 at 12:14

1 Answers1

0

You can do that like

<script>
   var val = "<?php echo $sommeanswered; ?>";
</script>
Syed mohamed aladeen
  • 6,507
  • 4
  • 32
  • 59