wilderp Posted August 1, 2011 Share Posted August 1, 2011 I have a php routine to read in a file to update about 57,000 records on a price list database. This works but can take more than 2 minutes so I've been looking for a way to display progress on the screen. Before the main loop is set:- @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); and at the end of each iteration I've got: $percentdone = round($_SESSION['linecount'] / $target * 100 , 2); echo "<script type=\"text/javascript\">document.getElementById('disp').innerHTML=\"$partnumber - $partdescription. " . number_format($percentdone, 2) . "% completed.\";</script>"; Although this creates a very large html file, it works very well and does not slow the process down too much. However, it leaves the screen totally blank in IE9 until the process is finished and as my users only use IE6(?) this is a problem. The only clue I have at the moment is the Platform, which IE reports as Win64 and all others seem to report Win32. Other than getting the users to use Chrome, any suggestions, please? Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/ Share on other sites More sharing options...
the182guy Posted August 1, 2011 Share Posted August 1, 2011 Here's another method which should work on most browsers (inc IE6): Launch the process by using an ajax call so that the page doesn't hang until complete and you still have full control over the page with javascript. When the processis launched, and as it progresses, keep updating the progress percent in a database or flat file. On complete have it echo out a status message e.g. 'success' or 'fail'. Then, have a seperate ajax call which goes to a different script to lookup the progress in the database or flat file, you can then update a progess bar or percentage text using the response of the ajax call. Have this call on a timer so that it checks the progess every 10 sec or whatever. When the first ajax call finishes, check the status and report it on your page, or if the progress check ajax call reports complete then display on the page and stop the timer. If there will be multiple users at the same time you'll need a unique ID to deferentiate between seperate progess data in the database. Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/#findComment-1250122 Share on other sites More sharing options...
wilderp Posted August 1, 2011 Author Share Posted August 1, 2011 I have a steep learning curve with ajax as I'm not familiar with it. Some pointers would be great, please. Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/#findComment-1250145 Share on other sites More sharing options...
the182guy Posted August 1, 2011 Share Posted August 1, 2011 Have a look at the Ajax with jQuery, it's very easy. Remember you're not doing anything special with the ajax calls, just simply calling the two PHP scripts: the one that launches the process and the one that is repeat called to get the progress percentage. Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/#findComment-1250168 Share on other sites More sharing options...
wilderp Posted August 1, 2011 Author Share Posted August 1, 2011 Many thanks. I'll give it a try. Any thoughts on why IE does not respond the same as Safari, Opera, Firefox etc.? Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/#findComment-1250178 Share on other sites More sharing options...
the182guy Posted August 1, 2011 Share Posted August 1, 2011 Unfortunately since the beginning of browsers, IE has seemingly done its own thing and often behaves differently to the other main browsers. Even IE6 will happily handle Ajax though, especially using the jQuery framework which is geared towards cross browser compatibility. Quote Link to comment https://forums.phpfreaks.com/topic/243456-making-progress/#findComment-1250183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.