refresh a part of webpage in php [closed]

PHP cannot do this, only a client-side language like JavaScript can. That being said, the jQuery library would allow you to do this really easily with its AJAX functionality.

Index.php

<div id="scores"><!-- score data here --></div>

Could be refreshed with the following JavaScript:

$("#scores").load("index.php #scores");

That would load the contents of #score from index again without refreshing the entire page.

You could even automate it to refresh every 30 seconds using setInterval();

var $scores = $("#scores");
setInterval(function () {
    $scores.load("index.php #scores");
}, 30000);

You can read more about $.load() at http://api.jquery.com/load/#loading-page-fragments.

Leave a Comment