This is is my case:
I upload an Excel file and each row is read into a table. Then each row in the table is processed before the user gets feedback. This processing can take some time.
How can I create a progress bar that shows how many % of the rows has been processed?
My solution is using MySQL, PHP and jQuery.
UPDATE
It seems people don’t understand my question.
I’m not asking how I can implement jQuery progress bar, that is the easy part.
I’m asking what logic do I need to implement in PHP to send data back after each insertion.
After I click Submit on my form, data + file is sent for processing. For each row inserted, I somehow want to update the progress bar.
Since the form data is submitted to it’s own page, I don’t see how I can use jQuery progressbar – even though I want to use it.
How do I send data back while the processing continues? Do I use some sort of CRON?
I don’t know if this would work for your current solution, and I don’t think I will provide any sample code because I can’t see your code. But I will at least type up my idea.
Since you are using MySQL you could create a table to hold the progress data of your processing.
For example you could store a ‘session ID’, a ‘total count of the rows in the file’ and the ‘last row which was processed’.
While you are processing your file’s rows you can
INSERT ... ON DUPLICATE KEY UPDATEthe progress table (The ‘session ID’ being your key).Of course if you have a large file this could be making more queries in your database than you really want, so you could for example update the table every 10 rows and then finally update when the last row is processed to lower the number of calls to your database.
While all of this is happening your user will be waiting on a page with your jQuery UI progress bar.
This page can make timed AJAX calls to a PHP file which would query your progress table to get the ‘last row number processed’ and the ‘total row count’.
Once you have this information returned via your AJAX call you can use the AJAX success function to do some simple maths with the ‘last row updated’ and ‘total rows’ number to update your jQuery progress bar.
When the progress bar is updated to 100% the AJAX could make one last call to delete the row from your progress table.
It isn’t perfect but it is an idea at least.
I’m sorry I can’t provide any sample code but I feel it would be a waste of time without seeing your current implementation and without knowing if this is the kind of solution you are looking for.