chineerat;11047543 wrote:I have a large MYSQL / PHP in a while loop report being run and in many cases the report times out due to the large amount of data being calculated.
Is there a way to make have a div displaying "Processing" when the while loops is calculating and if the report is completed , a div "complete" is displayed.
For example: The calculation are not complete because the variable $totals are not displayed. It is only when $Total is a rational value then "Completed" is displayed.
Many Thanks in advance!
<?php
session_start();
?>
<html>
<body id="dt_example">
<div "Processing">
<?php
while($noticia = mysql_fetch_array($query)) { // Very long mysql query , query usually times out in this loop. Div "Processing" shown
$Total +=$subtotal;
}
echo "Totals: ".$Total; //when this is executed , the report is succesful and div "Completed " is displayed
echo "<div Completed>";
?></tbody></table></div>
</body>
</html>
Well, the first thing to do is adjust your script timeout:
ini_set( "max_execution_time", $some_large_value_in_seconds );
Now, given that you have a browser, I assume, to view this, you might want to reconsider whether you really want your end-user to sit there that long waiting on the page to load. If the answer is "no" ... (my employer, for example, doesn't want to pay me to sit and do nothing while a program is doing something), then you might want to investigate RESTful interfaces (something like, "start the script via an AJAX call and have the UI on the page change when done".
It's a rather advanced topic ... how is your JavaScript-fu?