My code count and display total number of messages on index page.
I want to show only number of new messages. How to skip old messages or mark old messages as read?
CREATE TABLE IF NOT EXISTS `message` (
`id` bigint(50) NOT NULL AUTO_INCREMENT,
`name` tinytext NOT NULL,
`message` text NOT NULL,
PRIMARY KEY (`id`)
) ;
index.php
<script>
$(document).ready(function() {
$("#responsecontainer").load("MsgCount.php");
var refreshId = setInterval(function() {
$("#responsecontainer").load('MsgCount.php?randval='+ Math.random());
}, 1000);
});
</script>
New messages ( <?php echo"<b id='responsecontainer'></b>"; ?> )
MsgCount.php
$query = mysql_query("SELECT * FROM message");
$num_rows = mysql_num_rows($query);
echo"$num_rows";