4
I need a warning sound to be played after a bank appointment...
Logical example:
NUM_LINHAS = TABLE ROW NUMBER
SE (NUM_LINHAS > 0){
play();
}
My Java function that plays sound:
<audio id="audio">
<source src="alert.mp3" type="audio/mp3" />
</audio>
<script type="text/javascript">
audio = document.getElementById('audio');
function play(){
audio.play();
}
</script>
The "play()" function is working because I created a test button and the sound is played through the onclick()
<input type="button" value="test sound" onclick="play()";>
OK. Now I need this warning sound to be played after my consultation at the bank, which will have a condition.
Follows the code:
<?php
//seleciona o numero de linhas da tabela
$consulta = $conexao->query("SELECT COUNT(*) FROM toyota_base where statuz='NOVO'");
//atribui a variavel $num_rows o numero de linhas
$num_rows = $consulta->fetchColumn();
//verifica se o numero de linhas é maior que 0 (zero)
if($num_rows > 0){
//toca o som de alerta
echo "<script> play();</script>";
}
?>
I don’t know why the sound isn’t played anymore... I did a test with an "Alert()" instead of my "play()" function and Alert works correctly, but the sound does not play...