How to execute a php command dynamically during program execution

0

I'm doing a web application that displays a cam stream, however whenever I use it, it's necessary to reload the page, and I need it to happen automatically.

My idea is to dynamically run a query in the database using php , for the refresh page when the dial field value equals "0".

My attempt was as follows:

    <?php
     $sql = "select dial from ipstream where idusuario = '7';";
            while(true)
            {
                $retorno = mysqli_query($conexao, $sql);
                $linha = mysqli_fetch_assoc($retorno);
                if($linha['dial'] == "1")
                {
                    $sql = "update ipstream set dial = '0' where idusuario = '7';";

                    mysqli_query($conexao, $sql);

                    echo "<script>location.reload();</script>";
                }
            }
 ?>
    
asked by anonymous 03.11.2016 / 22:30

1 answer

0

Instead of using PHP to trigger javascript, do the reverse, use javascript / jquery to trigger PHP. And instead of reloading every page, reload only the content.

    
03.11.2016 / 22:41