0

hey i have little problem in this script, everything is working fine it show and delete from Database, the only problem i got that, it didn't show dynamic of database mean, it keep showing the msg even i delete is, and when i add new line in table it didn't get notify that there is new ligne, please some help guys! ty for your time

<script src="toastr/toastr.js"></script>

<script type="text/javascript">
setInterval(function ()
{
    <?php
    $dataMsg = mysql_query("SELECT * from toastr where id_user='$dataUser1[0]' and currency='BLK'");
    while($dataMsg1 = mysql_fetch_array($dataMsg, MYSQL_NUM))
    {
    ?>
        Command: toastr["<?php echo $dataMsg1[3]; ?>"]("<?php echo $dataMsg1[4]; ?>")
    toastr.options = {
      "debug": false,
      "newestOnTop": false,
      "progressBar": true,
      "positionClass": "toast-top-right",
      "preventDuplicates": false,
      "onclick": null,
     "showDuration": "5000",
      "hideDuration": "1000",
      "timeOut": "5000",
      "extendedTimeOut": "1000",
      "showEasing": "swing",
      "hideEasing": "linear",
      "showMethod": "fadeIn",
      "hideMethod": "fadeOut",
     "closeButton" : true,
    }
    <?php
    mysql_query("delete from toastr where id_toastr='$dataMsg1[0]'");
    }
    ?>
}, 10000);
</script>
  • You cannot run PHP code in javascript. Javascript runs on the browser and PHP runs on the server – RiggsFolly Jul 19 '18 at 21:48
  • ___Also___ Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Jul 19 '18 at 21:49
  • ok how i can featch json table returned by ajax(call php file) in javascript! – Achraf Abdmouleh Jul 19 '18 at 21:53

0 Answers0