I’m using PHP, i want to play sound file when new record added to database but i need to play that sound only once. i try below code with click function & it works
<?php
if(isset($_REQUEST["action"]))
if($_REQUEST["action"] == "play")
{
?>
<embed src="Kalimba.mp3" autostart="true" loop="false" style="width:5px; height:2px;">
<?php
}
?>
When click on play link it start that mp3 file
<a href="sound.php?action=play">Play</a>
To play a sound on a website (pretty universally), you’ll want to look into sound manager 2:
http://www.schillmania.com/projects/soundmanager2/
If you are asking how to know when a new record is added to the database while the visitor is viewing a page (you want live checking and notification), you’ll need to use ajax to fetch the highest id (or something to identify the newest record) and compare the unique identifier with javascript to the previous last id. If they do not match, a new record was added and you should trigger playing the sound.