You can accomplish this with AJAX (Asynchronous JavaScript and XML), but be warned calling a database that much can make your site slow. Obviously it'd take many users to make it slow, but this is a fair warning. You might also want to program a time out function where if the user hasn't done anything in X
amount of minutes, don't submit Y
into the database.
But here is the basics of what you're trying to accomplish.
<script type="text/javascript">
function myAwesomeFunction(){
$.ajax({ url: '/path/to/mysqlcalling' }).done(function(data){
//Call back data. The data variable is your callback data, though you will have to figure out how you want it to be used.
setTimeout('myAwesomeFunction()',5000); //5 seconds = 5000 milliseconds
});
}
</script>
I'm going to assume you're using jQuery, otherwise this will be a painful step. You could also use jquery's POST functionality, but if you're not submitting data and are just calling the database, this is sufficient.
More information on jQuery's AJAX Function.
More information on jQuery's POST Function.