I have a PHP page with this structure:
<?php
include 'header.php';
include 'content.php';
include 'footer.php';
?>
In the header.php, I have a function that counts some rows in a database.
$show =$mysql->count('someparam', $foo['bar']);
if ($show > 0) {
echo $show;
}
That's all good. Now, in the content.php file, the user can do operations that changes this $show value in the header, but I need to reload the page to see the updated $show number.
I want to solved this with JavaScript, but can't figure out how to do it.
I tried solving it with a JavaScript reload on timer, like this:
<script>
function render (){
$('.customer-database').html(.customer-database)
}
window.setInterval(render, 500);
</script>
the $show counter is inside the div class costumer-database. This is not working because I need to put the HTML code in after the HTML, but I don’t want to put HTML code in. I simply want to reload it. Is this possible?
I am open to any suggestions in both JavaScript and PHP.
ajax: you make a call (in javascript) to a URL which will return you the processed html code with the updated values.