I have a cycle. it holds quite a long time, I need to visualize the process work. how to do this?
while ($csvIterator->next()) {
//a lot of code...
visualizeProcess();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT
-This assumes you are using PHP for web-based applications.
In short, there is no easy way to do this. There are a lot of areas in which you would need to design your application smartly to handle it (ie: if you’re building a page piece by piece then what happens if its supposed to be secured? You’ll need to implement SSL and make sure that all AJAX calls are encrypted). Basically what you need to do is have the script executable in blocks, instead of having a loop that does the operation in its entirety on its own. For instance, have a php file that takes an integer as a query string and then uses that integer to do a different action. Once the integer is equal to a certain number you can be sure that everything you needed to do has been done and therefore progress makes it to 100%. You cannot have PHP send a page piece by piece back to a browser, which is what it seems you are proposing to do. You need to use AJAX calls (assuming this is a web application instead of a command line application). Do something like the following:
Create a PHP file that takes in an int via query string. Have the integer that is passed along dictate the action that the PHP script undertakes (ie: 0 = get all session variables allotted, 1 = connect to the database and get the data you need to parse and push it into session, 2 = parse the data from session and do something).
Create a PHP file that will be served to the client as the base page that will show the progress. From this page you will need to use Javascript to request the page mentioned in 1 with the various query strings. The AJAX calls that you issue have success and failure handlers, and in these you will be able to change what is being displayed on the page to reflect how the process is coming along.
In short there is no easy way to do progress bars for web applications due to the nature of their distribution. I suggest that you look in to the way GET and POST requests work, the functionality of web servers, and the way that the PHP handler works w/ Apache to get a better idea of why your initial approach isn’t viable.