0
<script>

     scanner.render(success, error);
    // Starts scanner

    function success(result) {

        let today = new Date().toISOString().slice(0, 10)

        const date_obj = new Date();

        time = new Date().toLocaleTimeString();

document.getElementById('result').innerHTML = `

        <div class="card" style="width: 25rem; onload="console_log(${result};">

        <img src="../assets/img/barcode-scan.gif" class="card-img-top" alt="...">

        <div class="card-body">

        <form action="index.php?page=validator" method="post">
        
        
        
```
<?php
        include '../pages/koneksi.php';
        $result=${result};
        $result_explode = explode($result);
        $e_result1=$result_explode[1];
        
        $new2="SELECT * FROM `barang` WHERE Barcode=$result";
       $res2=mysqli_query($koneksi, $new2);
    while($row=mysqli_fetch_array($res2)){
   echo $row['Nama'];
   echo $result;
    }
?>
```

</script>

I Want to get data from ${result} converting to $result, to get MySQL data using where Barcode=$result.

But I didn't get something,

but when I change the Barcode=$result to data basic like Barcode=0101011, then I get the value of the echo result as the scanned barcode.

Please give me a favor.. thanks.

Ismaili Mohamedi
  • 906
  • 7
  • 15
  • I can't tell whether you want to [send server-side PHP data to client-side JavaScript](/search?q=send+php+variable+to+javascript) or [send client-side JavaScript data to server-side PHP](/search?q=send+javascript+variable+to+php), but both are well-covered by previous questions and answers here, such as the ones I've linked: [1](https://stackoverflow.com/questions/23740548/) [2](https://stackoverflow.com/questions/1917576/) – T.J. Crowder May 19 '23 at 06:12

0 Answers0