X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A8D79D1B452 for ; Tue, 16 Dec 2003 10:06:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06475-07 for ; Tue, 16 Dec 2003 06:06:21 -0400 (AST) Received: from orioninformationservices.com (oismail.com [213.173.245.221]) by svr1.postgresql.org (Postfix) with ESMTP id 245EBD1B4DF for ; Tue, 16 Dec 2003 06:06:18 -0400 (AST) Received: from eladrin (port259.ds1-brh.adsl.cybercity.dk [217.157.160.140]) (authenticated) by orioninformationservices.com (8.11.6/8.11.6) with ESMTP id hBGA6Rc11786 for ; Tue, 16 Dec 2003 11:06:27 +0100 From: "Jona" To: Subject: Re: A progress page with PHP + PostgreSQL Date: Tue, 16 Dec 2003 11:05:59 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/42 X-Sequence-Number: 2488 What you could do is utilize the php flush() function while your script is looping Please note however that although this function clears the internal output buffer in PHP, it doesn't affect the output buffer in your webserver (if such is used), neither does it prevent the user's browser from caching in its input buffer (most browsers have an input buffer on 256 bytes) There's a work around to the browser input however, something like the following should do the trick if used as step 2) and 3) as it does both the work and displays the progress bar. Progress" . "
"; // Append blank spaces to fill browsers input buffer $sOut = $sOut . str_repeat(" ", 260 - strlen($sOut) ); // Display headline echo $sOut; // Flush PHP output buffer flush(); // Loop through recordset while($RS = pg_fetch_array($res) ) { /* Do your calculations with the current record */ // Progress bar $sOut = "# "; // Append blank spaces to fill browsers input buffer $sOut = $sOut . str_repeat(" ", 260 - strlen($sOut) ); // Display next echo $sOut; // Flush PHP output buffer flush(); } ?> Of course this will only work if you return your recordset in chunks to PHP, should you however utilize a PostGre function to do some heavy calculations (and thus having all your work in the database) PHP making a progressbar is a bit more tricky. In this exampla you might want to consider counting the number of records first so you can give the user an idea of how long the progress actually is instead of simply showing progress. Hope this helps /Jona -----Original Message----- From: pgsql-php-owner@postgresql.org [mailto:pgsql-php-owner@postgresql.org]On Behalf Of Thom Dyson Sent: 15 December 2003 21:23 To: pgsql-php@postgresql.org Subject: Re: [PHP] A progress page with PHP + PostgreSQL I've never done this, but my first guess would be to send the user to a temp page after step 1. This temp page would have some animated gif so the user thinks something is happening (step 3). After a fixed time period (equal to the loop time on the gif), the temp page auto-redirects to a new page that shows the final results (step 4) Thom Dyson Director of Information Services Sybex, Inc. On 12/15/2003 11:30:06 AM, Sai Hertz And Control Systems wrote: > Dear all, > > Permit me to gain some of your most valuable knowledge ........... > > In one of our application a process takes time and as the work is in > progress we want to show our customer a progress bar > or processing page > It is some thing like this > > 1. Customer Clicks on button EXECUTE > 2. The pgsql function is invoked > Now normally after step 2 a success page will return only after the > postgresql function finishes > but we would like as > 3. Show progress of executed function > 4. On Sucessfull completion Show Success page > else error page > > Would be greatefull to all for any tiny clue. > > > Regards, > Vishal Kashyap > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings