Re: Progress bar?

From: Date: Fri, 08 Dec 2000 14:42:04 +0000
Subject: Re: Progress bar?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-29352@lists.php.net to get a copy of this message
Jay, I take it you are looking at a function to display a status bar mostly for long queries. How about doing 5 queries to return the same results and then incrementing the status by 5 each time one of the queries has been completed. Like this 1. Run a query to return the total number of records: $totalrecords. 2. Divide this value ($totalrecords) by 5: $recorddivision 3. Set a starting point value: $starter 4. Set records variable: $records = $recorddivision 5. Iterate through a Loop (5 Times) 6. Set query 1 to be :SELECT * FROM ..... LIMIT $starter, $records 7. Increment loop adding $recorddivision value to $starter and $records 8. On each iteration send a response to the browser to increment the status bar. This would add network traffic and page load times but could work as long as your query isn't too complex. Let me know what you think. Andy www.databasewatch.com ----- Original Message ----- From: "Jason Lavigne" <jlavigne@stonecroft.net> To: "Miles Thompson" <milesthompson@sprint.ca>; <murph@murphatnight.com> Cc: <php-general@lists.php.net> Sent: Saturday, December 09, 2000 2:01 AM Subject: Re: [PHP] Progress bar? > This bar would not get that until after the query was done, but if there was > processing, comparing data from query with user input, then at that time the > status bar would "kick" in and give feed back. Like this: > > 1) Query DB > 2) Return number of rows to browser > 3) Processing a row from result > 4) Update the record count to the browser > 5) Go to 3 if not done > > This would at least tell the user about how many records are left to > process. > > On most queries, this bar would be up for a second or two, but for heavy > data processing ( checking inventory against what ever, 100,000+ records ) > it could be useful. > > Yes the JavaScript end could be mean but in the PHPChat Example > (http://www.phpwizard.com) they did a good job at handling it. > > The DHTML or Flash is only used to display a message and a % with a bar. > Nothing more. > > Now the more I think about it, this could be useful, a couple of functions, > > StartProgressBar() - Would open the streaming window with DHTML. Default > message "Please wait, initializing." > SendProgressStart() - Would be the total num, ie... num of records, 100 or > what ever number you wanted to mean "this is the end number". > SendProgressMessage() - Would send a text message to the window for the user > "Updating your file.....Please wait...." > SendProgress() - This would be the update number, this would make the "bar" > move and the % number update. > > By default, when SendProgress() reaches 100%, the DHTML and/or Flash would > shut itself down and display the output from the system. > > I never said nor implied that this would be for a beginner to create, this > would be for an advanced programmer to tackle. > > I just do not like people saying "That is not possible", it is ALWAYS > possible, just look at it in a different way :) > > Jay > > ----- Original Message ----- > From: "Miles Thompson" <milesthompson@sprint.ca> > To: "Jason Lavigne" <jlavigne@stonecroft.net> > Cc: <murph@murphatnight.com>; <php-general@lists.php.net> > Sent: Friday, December 08, 2000 8:26 AM > Subject: Re: [PHP] Progress bar? > > > > Jason, > > > > Very impressive - but what SQL engines provide a count of records as they > > process? Or is that a part of the MySQL / PostgreSQL docs I haven't > uncovered > > yet? > > > > I do believe, with all the Javascript and DHTML it would be an ongoing > > maintenance headache. > > > > I'm also curious about the original poster's query, which apparently takes > so > > long to run. Full join on a big table? > > > > Miles > > > > Jason Lavigne wrote: > > > > > If you were to use a streaming HTML window from PHP ( as seen in PHPChat > on > > > http://www.phpwizard.com ) you can keep sending data > > > to the browser > without > > > reposting ( read about flush() ) to the server. So if you did this you > could > > > do the following in PHP: > > > > > > Do select from SQL and return Num of rows (use a function that counts > the > > > total number of records from the select) and send that to the browser. > > > As you process each record you could send back to the browser that you > > > processed X records. (I would send this update after 10 records or add > code > > > that after each % that was done I send back that number) > > > At this time the browser has the total number of records and is > receiving > > > the record number that was processed (10 out of 100 etc...) > > > Then using JavaScript you could feed those values in to DHTML or Flash > to > > > graphically do a status bar. > > > > > > Is there another solution? I am sure there is, but it is not impossible. > > > > > > Let me know if you do do this, I would be interested is seeing in > working :) > > > > > > Jay > > > > > > ----- Original Message ----- > > > From: "Miles Thompson" <milesthompson@sprint.ca> > > > To: "Murph" <murph@murphatnight.com>; "PHP General List" > > > <php-general@lists.php.net> > > > Sent: Friday, December 08, 2000 7:25 AM > > > Subject: Re: [PHP] Progress bar? > > > > > > > If you did one you'd have to fake it. Think about it, the web is > stateless > > > environment, no channel is opened and maintained to the back end, and > SQL > > > queries are essentially the same. If a progress bar > > > > displays while a SQL query executes, it's provided by the database > vendor. > > > > > > > > If you did have feedback from the SQL engine you would need to keep > firing > > > new pages to the browser. > > > > > > > > Regards - Miles Thompson > > > > > > > > Murph wrote: > > > > > > > > > Hi! > > > > > > > > > > Has anyone invented a progress bar that displays on a web page to > > > entertain the viewer while they wait for a query to finish? I'd be > > > interested in getting a pointer to a snippet of code if you have it. > > > > > > > > > > Yours, > > > > > Murph > > > > > > > > > > www.murphatnight.com > > > > > __________________________________________________________________ > > > > > Brian Murphy - 193A Lowell St., Apt. 24 - Methuen, MA 01844 - (978) > > > 725-6654 > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#29352) next »