I'm building a website that prints the content in it's Mysql database to the page for the user to see. The database's content is going to be constantly added to, and I want to show those changes in real time on the page without the user having to reload. I'm using PHP to echo the contents of the database to the page right now and it works great, it's just that to see any new changes, the page has to be reloaded. So my question is, how do I make the page update itself in real time? I'm guessing this is going to involve Ajax but I'm rather new to javascript...
Would you guys mind pointing me in the right direction?
Here's what my database looks like:
id author body
----------------------------------------
1 jim sample content
2 bob more content
3 fred some more!
I'm using the following PHP code to print the above data to the web page:
$query = mysql_query("SELECT * FROM log order by id desc") or die(mysql_error());
while($row = mysql_fetch_array($query)) :
echo $row['author'];
echo $row['body'];
endwhile;
Thanks!
setInterval(), it will call a function every x secs