Fearpig Posted August 23, 2007 Share Posted August 23, 2007 Hi guys, Can anyone recommend a % progress bar for me!! I've got a fairly simple page that queries a huge database and takes about 30 seconds to return data, is there anyway to put up an intermediate progress bar showing percentage (of time or data) remaining? I just can't work out how I'd predict how much time the next page will take to load! If a % progress bar can't be done... is there a way of putting in a holding page until the query has finished? (It'd just be a blank page with a spinning swf or animated gif.) Any help would be appreciated. Tom Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/ Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 I just can't work out how I'd predict how much time the next page will take to load! Animated gif would be better then as with a processbar percent your need to know how long the way i work it out is something like this 1. get the current time = StartTime 2. get the number or items/records etc = R, 3. during the processing, after echo records, i do RT = Total Records RP = Records processed so far PerRecord = ((Current Time - StartTime) / RP) TimeRemaining = ((RT - RP) * PerRecord) i hope that makes sense but Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-331831 Share on other sites More sharing options...
Fearpig Posted August 24, 2007 Author Share Posted August 24, 2007 Thanks MadTechie, That all makes sense but I wouldn't have a clue where to start! How would you get hold of the value for records processed so far? How would you display the animated gif or holding page until the records are processed? I'll keep searching but any help would be appreciated as always. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332850 Share on other sites More sharing options...
Cobby Posted August 24, 2007 Share Posted August 24, 2007 Thanks MadTechie, That all makes sense but I wouldn't have a clue where to start! How would you get hold of the value for records processed so far? How would you display the animated gif or holding page until the records are processed? I'll keep searching but any help would be appreciated as always. I think it would have to be done with AJAX. I don't know much about it, but I think AJAX uses something similar to javascript to make PHP interactive without reloading the webpage. Its possible it could be done with javascript. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332884 Share on other sites More sharing options...
Fearpig Posted August 24, 2007 Author Share Posted August 24, 2007 OK!... my Javascript skills are pretty lousy and I'm not even sure what AJAX is! Is there a way to put up an intermediate page until the results page is displayed? I'm now thinking of using a spinning timer (or equivalent) instead of a % progress bar. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332899 Share on other sites More sharing options...
Barand Posted August 24, 2007 Share Posted August 24, 2007 I use animated gif / AJAX combination for such things The page has a placeholder for the results <div id="results"> <!-- PLACHOLDER --> </div> In the js function which is initiating the xmlhttp request have document.getElementById("results").innerHTML = "<img src='spintimer.gif'>"; Then when the call completes, place the returned results in the DIV, replacing the gif. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332902 Share on other sites More sharing options...
Cobby Posted August 24, 2007 Share Posted August 24, 2007 You could always go to a page that has a looping loading bar or similar, and just go to the results page after 40 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332903 Share on other sites More sharing options...
Fearpig Posted August 24, 2007 Author Share Posted August 24, 2007 Right then, solutions ago-go!! Barand your idea seems the best bet, I've used replacing div elements for changeable content on tabs but how on earth would I get the content to change once results have been returned? I think its probably best to start with the basics... can anyone recommend a tutorial? Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332907 Share on other sites More sharing options...
Barand Posted August 24, 2007 Share Posted August 24, 2007 one in my sig Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332913 Share on other sites More sharing options...
Fearpig Posted August 24, 2007 Author Share Posted August 24, 2007 Doh!! Cheers for your help again Barand. I'll marked this as solved although it'll take me a good while to do it! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/66313-solved-progress-bar-during-server-side-query/#findComment-332932 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.