How to run a php command dynamically while running the program

Asked

Viewed 76 times

0

I’m making an application web that displays a video stream, but every time I use it, you need to reload the page, and I need it to happen automatically.

My idea is to dynamically execute a query in the bank using the php, for the page update when the field value dial is equal to "0".

My attempt was the following:

    <?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>";
                }
            }
 ?>

1 answer

0


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

Browser other questions tagged

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