on 1/29/04 7:50 AM, Dave Carrera at [EMAIL PROTECTED] wrote:

> Hi List,
> 
> I have a test function who's aim is to take an array an do something which
> each value of the array and show the result on screen one at a time.
> 
> --- Test Function Code ---
> 
> function TestFunc(){
> $cnt = array(1,2,3,4,5,6,7,8,9,10);
> $i=0;
> 
> while($i <=count($cnt)){
> set_time_limit(2);
> echo $cnt[$i].str_repeat(" ", 300) . "<br />";;
> ob_flush();
> flush();
> $i++;
> }
> 
> --- End ---
> 
> This just shows the output after processing all of the function which is the
> behaviour of php as a server side engine, but after reading the manual I
> thought the combination of flush() and ob_flush() would do what I wanted,
> but I obviously got the wrong end of the stick which flush() and what is
> dose.
> 
> So I ask the list if there is a way to show success or fail results for each
> of the values of an array one at a time:
> 

i don' think there's a reliable way to do this since you're relying on the
browser to display these items as PHP prints them out. as someone else
pointed out some browsers don't render items as they load and instead wait
for all the page to load before rendering the page. this is especially true
of pages using tables.

perhaps a workaround would be to use a little DHTML (CSS & Javascript).

i don't have the exact code but i'm fairly confident it can be done. here's
the concept:

- when looping through each value place each in its own DIV with a unique
ID, i.e., result$cnt[$i]. All DIVs should be styled so that they are NOT
visible. (i.e., the page loads, all DIVs are loaded but are hidden). you can
do this through visibility = "hidden" or display = "none"

- create/find a Javascript show/hide layer script that also has a timer
function. since you've given each DIV it's own unique ID based upon the
$cnt[$i] value, you can reference these within the Javascript by doing a
similar loop. in the loop you'll identify each layer by it's unique ID and
change it's visibility = "visible" or display = "block". in between each
item in the loop you can add a pause (similar to what you were trying in the
PHP code).

hope this is clear enough and hope it helps.

regards,
brian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to