如何在所有页面中更新包含php而不刷新

I need update only a part of the page where its included an include php with a specific path. How update only this file included with this include.

Code is this:

<tbody>
   <?php include_once "tabelas/table.php";  ?>
</tbody>

What I am doing in really is calling a function javascript that do update and it do update, but it not do update in this include php. Thanks advance!

(i dont want do require in ajax because it is a datatable and in this case it just work with include php, so i need a solution in php preferenly)

You cannot update only part of a page with PHP without using AJAX. The Javascript AJAX call will run a PHP script that can access the database using PHP and will return the results.

You will need a Javascript function to make the AJAX call:

<script>
function jsupdate(returnid) {
 xmlhttp=new XMLHttpRequest();
 xmlhttp.onreadystatechange=function()  {
 if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById(returnid).innerHTML=xmlhttp.responseText;
 }
}
xmlhttp.open("GET","databasecall.php,true);
xmlhttp.send();

}

Then you will need a PHP script called "databasecall.php that accesses the database, so would contain something like:

//first include your database connection

 $sql = "SELECT * from mytable limit 1 ";
 $result = mysql_query($sql) or die ('Error: XXX000');
 if (mysql_num_rows($result) > 0) {
  $row = mysql_fetch_array($result);
  echo $row[0];
 }
 else {
   echo 'No such database table entry';
 }

The echo-ed results are returned to the Javascript.

It really depends on when you are trying to update the info in the included page.

If you want to update it after the page has processed, you will have to use JavaScript + Ajax to load and update when necessary.

If on the other hand you are trying to do it while the page is still processing, you can use variables + objects + arrays to store the output data. That way you can update them when needed. Then at the end of processing you can actually output/echo/print the data.

Many people accomplish this by using the DOM extension in php, or using Output Buffering.