I've got a browser-based app that downloads a bunch of stuff from a remote server, and I'm using the str_pad
trick mentioned in this answer to push output incrementally. Something like this:
Downloading records for Property 1 into table rets_property_1
Query: (181=1980-03-01T00:00:00+),(18=1980-03-01T00:00:00+) Limit: 100
Selected fields: sysid,1,2,3,4,5,6,7,8,9,10,11,13,15,16,17,18
Fetching listings from server, please wait...
Number of listings returned: 100
. Downloading images
Images found: 2
Images downloaded: 2
. Downloading images
Images found: 1
Images downloaded: 1
. Downloading images
Images found: 4
Images downloaded: 4
... etc
I want to keep the browser scrolled to the bottom at all times, with the option to scroll back up, kind of like what you'd see using the command line.
Not sure if this is an obstacle, but there's no way I can think of to have closing tags on anything because of the way the output is being sent (the closing tags wouldn't be sent until after all the other output).
echo '<html><body>'; // first output sent
$obj->download_listings(); // takes a long time, sends output incrementally
echo '</body></html>'; // too late to be useful
Is there any way to make sure the newest piece of output is always displayed on the screen (which would be at the bottom after the screen is full)? I'm open to using even the hackiest of ideas using PHP, HTML, JS, or CSS.