I’m trying to get a span to refresh with a php function which queries the database for spaces. However, I can’t figure out how to keep it refreshing the actual database content dynamically (preferably via a timer). Here’s what I have so far
<script type="text/javascript">
window.onload = startInterval;
function startInterval()
{
setInterval("startTime();",1000);
}
function startTime()
{
document.getElementById('spaces').innerHTML = <?php echo get_spaces($id)?>;
}
</script>
You’re going to have to use Ajax to load content dynamically without reloading the page.
You will have to make a PHP script that will output only the content you want to load dynamically on the page and then load this script with Ajax.
There is an easy way to do this with jQuery, see this example: http://www.sitepoint.com/ajax-jquery/