Jump to content

[SOLVED] % Progress Bar during server-side query


Fearpig

Recommended Posts

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.  ;D

Tom

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.  ;D

Link to comment
Share on other sites

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.  ;D

 

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Right then, solutions ago-go!!  :o

 

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.