Page 1 of 1
displaying results each...
Posted: Wed Jun 19, 2002 8:33 pm
by Jose Arce
Hi again..while runnig several process, with while, how can i display the results soon as one is finished, without wating untill the others are finished?
Posted: Wed Jun 19, 2002 8:57 pm
by kaizix
if you have an echo $variable; in the while loop, everytime it comes to that, it'll echo out the value...
Posted: Wed Jun 19, 2002 8:59 pm
by Jose Arce
thx!
i do have an echo $variable...but it keeps waiting untill the whole loop are finished
Posted: Wed Jun 19, 2002 9:02 pm
by kaizix
you may need to use print instead of echo with while.. print $variable;
Posted: Wed Jun 19, 2002 9:07 pm
by Jose Arce
i'll check...thx!
-------------------------------------------------
It's not working

-------------------------------------------------
Posted: Thu Jun 20, 2002 1:43 am
by twigletmac
echo and
print are basically the same thing. The only difference is that print can be called using a
variable function.
So there's really no difference between,
Code: Select all
print $variable;
// and
echo $variable;
Mac
PS. If it's not working post some code so that we can help a bit better.
Posted: Thu Jun 20, 2002 2:08 am
by kaizix
i figured there wasn't much of a diff. but looking at the manual for
while, it had print so i was think it might interact differently in that respect. otherwise, i wouldn't see why it would wait until the end.
Posted: Thu Jun 20, 2002 2:16 am
by twigletmac
Code: Select all
while (conditions) {
echo $variable;
}
and
Code: Select all
while (conditions) {
print $variable;
}
do the same thing. I think what he meant was he had something like:
Code: Select all
while (conditions) {
$variable .= something;
}
echo $variable;
which is why it would only echo at the end.
Mac
Posted: Thu Jun 20, 2002 2:34 am
by kaizix
exactly.

Posted: Thu Jun 20, 2002 6:14 pm
by Jose Arce
twigletmac wrote:Code: Select all
I think what he meant was he had something like:
їcode]while (conditions) {
$variable .= something;
}
echo $variable;
which is why it would only echo at the end.
Mac
I mean exactly the same...so..echo at the end fo the while?
Posted: Thu Jun 20, 2002 6:36 pm
by Jose Arce
actually...what i really mean goes like this:
Code: Select all
while(conditions) {
$anotherprocess
if ($anotherprocess) {
HERE GOES THE ECHO OR PRINT?
}
}
OR HERE?
so thats the deal...hope u can help me
Posted: Fri Jun 21, 2002 2:28 am
by twigletmac
If you want the information to display each time the loop goes round:
Code: Select all
while(conditions) {
$anotherprocess;
if ($anotherprocess) {
echo $variable;
}
}
If you want to put all the information into one long string and echo it once the loop is finished:
Code: Select all
$variable = '';
while(conditions) {
$anotherprocess;
if ($anotherprocess) {
$variable .= $info;
}
}
echo $variable;
Mac
Posted: Fri Jun 21, 2002 5:40 pm
by Jose Arce
it's not workin for me...

...i guess webservers hate me jeje...
Posted: Fri Jun 21, 2002 5:57 pm
by will
Jose Arce wrote:it's not workin for me...

...i guess webservers hate me jeje...
no, i've had the same problem.... and i'm not sure there is a work around. for example i'll do a really complex MySQL query that ends up returning a thousand or so results. none of the results will show up until they are all finished, then they are all thrown to the page.
it may be a long shot, but you may see what ticks do. they are designed to execute every nth time through a loop... not sure if you could set n=1 and have the tick print your stuff.... it's worth looking into at least.
http://www.php.net/manual/en/control-st ... eclare.php
Posted: Fri Jun 21, 2002 6:59 pm
by Jose Arce
ok...seems very nice, but a bit complex, maybe someone should give us a better explanation of ticks
