I am developing a Queue System Managment with PHP and MySQL. To summarize, I have a database which saves the 4 kinds of ticket that you can get. When the people who work here want to call the next person, they have a dashboard with a button that adds +1 to the MySql table current value. Then, I have a query to read data from the database which is updated every second to the index.php. It seems a little confusing but it works haha. The thing is - we have been having an issue, which is, people never know when its their time. We would like to implement a sound, so when someone is called, a sound is played
Index.php:
<div id="show"></div>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setInterval(function () {
$('#show').load('data.php')
}, 1000);
});
</script>
Data.php
$result = $conn->query("SELECT alunos FROM senhas");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="alunos">';
echo $row['alunos'] . '<br>';
echo '</div>';
}
}
$result = $conn->query("SELECT sase FROM senhas");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="sase">';
echo $row['sase'] . '<br>';
echo '</div>';
}
}
$result = $conn->query("SELECT matriculas FROM senhas");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="matriculas">';
echo $row['matriculas'] . '<br>';
echo '</div>';
}
}
$result = $conn->query("SELECT outrosassuntos FROM senhas");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<div class="outros">';
echo $row['outrosassuntos'] . '<br>';
echo '</div>';
}
}
matriculasavancar.php (it makes the category "Matriculas" avance 1 value)
$sql = "UPDATE senhas set matriculas = matriculas+1";
mysqli_query($conn, $sql);
header("refresh:0; url=admin.php");