0
Good morning to all!
Good! I would like a great help from you. I am trying to make a Call panel of patients very simple for when the doctor is in the office see a table of patients and click the desired name and in the reception room appear his name and play a sound. At the moment I can only make it play a sound on the PC that is called that would be the doctor, because it would not be ideal since I would have to put sound boxes outside for each office.
This is my code:
**db.php**
<?php
$servidor = "localhost";
$usuario= "root";
$password = "";
$db = "painel";
$conexao = new mysqli($servidor, $usuario, $password, $db);
?>
**chamar.php**
<?php
include "db.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>CHAMAR CLIENTE</title>
<link rel="stylesheet" type="text/css" href="estilos.css">
</head>
<body>
<div id="conteudo">
<form method="POST" action="chamar.php">
<input type="text" name="nome">
<input id="id2" type="submit" name="enviar" value="Chamar Paciente"
onclick="ajax();">
</form>
<?php
if (isset($_POST['enviar'])) {
$nome = $_POST['nome'];
$consulta = "INSERT INTO chamar (nome) VALUES ('$nome')";
$executar = $conexao->query($consulta);
if ($executar) {
//EXECUTA O SOM QUANDO É INSERIDO UM REGISTRO
echo "<embed loop='false' src='beep.mp3' hidden='true'
autoplay='true'>";
}
}
?>
</div>
</body>
</html>
**index.php**
<?php
include "db.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>PAINEL DE CHAMADA</title>
<link rel="stylesheet" type="text/css" href="estilos.css">
<script type="text/javascript">
function ajax(){
var req = new XMLHttpRequest();
req.onreadystatechange = function(){
if (req.readyState == 4 && req.status == 200) {
document.getElementById('chamar').innerHTML = req.responseText;
}
}
req.open('GET', 'painel.php', true);
req.send();
}
setInterval(function(){ajax();}, 3000);
</script>
</head>
<body>
<div id="conteudo">
<div id="div-chamar">
<div id="chamar"></div>
</div>
<?php
$consulta = "SELECT * FROM chamar";
$executar = $conexao->query($consulta);
if ($executar) {
//SÓ EXECUTA O SOM QUANDO É ATUALIZA A PÁGINA
echo "<embed loop='false' src='beep.mp3' hidden='true'
autoplay='true'>";
}
?>
</div>
</body>
</html>
**painel.php**
<?php
include "db.php";
$consulta = "SELECT * FROM chamar ORDER BY id DESC";
$executar = $conexao->query($consulta);
$chamar = $executar->fetch_array();
?>
<h1 id="prova" class="mudar" style="color: #1C62C4; font-size: 80px;"><?php echo $chamar['nome']; ?></h1>
Agradeço desde já!!!
can send the structure of the bank so I can replicate here and make a test?
– Will Knippelberg