just increment it, then echo it out... um, not hard eh? But if you want to use flush(), you'd need to know how to use buffers.
ob_start();
for($i=0;$i<100;$i++) {
$counter++;
echo $counter;
for($a=0;$a<50;$a++) {
$counter2++;
echo $counter2;
}
ob_end_flush();
That would start a buffer, put it all in the buffer, and when ob_end_flush() is called, would print it all on the screen...