SuperMyKel Posted April 20, 2010 Share Posted April 20, 2010 This may seem kind of convoluted, but I am regularly uploading and importing an excel spreadsheet to a web application written in php/mysql. I would like to see the progress of the process while the spreadsheet is read in, parsed and inserted into the database. Short synopsis of the process. File is uploaded via form File is parsed via php line for line for each line some criteria are evaluated if pass then insert else go to next line of spreadsheet I would like to see a display of the process, progress bar, display of spreadsheet data currently being inserted, that sort of thing. I have tried to wrap my head around the process, but can't quite figure out how to do it with the current script that I have as it is all done in one script, and I can't see how it would answer the ajax calls to display each successive insert. Thanks in advance for any help you might have. Quote Link to comment Share on other sites More sharing options...
andrewgauger Posted April 20, 2010 Share Posted April 20, 2010 You can use javascript for the updates, executing a function that updates some for of user interface. To make a percent, you would need the total lines to be evaluated. Pass that to a javacript function function setComplete(total){ GLOBAL_total=total} and you would need to have placed GLOBAL_total and GLOBAL_curPos before the <body> inside a <script> then after every (or maybe every 10--don't know how many lines were talking) execute a: function setCurPos(pos){ GLOBAL_curPos=pos updateUI() } function updateUI(){ document.getElementByid("progress").innerHTML=(GLOBAL_curPos/GLOBAL_total) } [code] This will all work if you have a <DIV id="progress"></DIV> somewhere on your php page (before you start executing the upload/processing) Again on every line you are going to have to: [code=php:0] echo "<script language=\"javascript\">\n setCurPos($i)\n</script>"; $i++; This probably isn't super efficient, but there is going to be overhead. To do what you want.[/code] Quote Link to comment 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.