JS Code (this query use header file)
<script type="text/javascript">
var old_count = -1;
setInterval(function(){
$.ajax({
type : "POST",
url : "file.php",
success : function(data){
if ( old_count != -1 && data > document.getElementById('hiddenfiled').value){
old_count=data;
document.getElementById('hiddenfiled').setAttribute('value',data);
alert("New employee added");
}
else
{
old_count=data;
document.getElementById('hiddenfiled').setAttribute('value',data);
}
}
//alert(data);
});
},1000);
</script>
And the PHP code: (file name: file.php)
<?php
include("config.php");
$sql = "SELECT COUNT(*) as count FROM `tblemployee`";
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
echo $row['count'];
?>
<script type="text/javascript">
var old_count = -1;
setInterval(function(){
$.ajax({
type : "POST",
url : "file.php",
success : function(data){
if ( old_count != -1 && data > document.getElementById('hiddenfiled').value){
old_count=data;
document.getElementById('hiddenfiled').setAttribute('value',data);
alert("New employee added");
}
else
{
old_count=data;
document.getElementById('hiddenfiled').setAttribute('value',data);
}
}
//alert(data);
});
},1000);
</script>
And the PHP code: (file name: file.php)
<?php
include("config.php");
$sql = "SELECT COUNT(*) as count FROM `tblemployee`";
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
echo $row['count'];
?>