|
LITTLEBLACKDOG.COM
|
| Author |
Message |
fathertyme
Site Admin


Joined: 30 Jun 2001 Posts: 6213
Location: The American Colonies
|
Posted:
Tue Feb 18, 2003 1:01 am Post subject: display output before php code ends... |
|
so I've got a rather hefty set of PHP code, that I run on a regular basis. it takes like 5-15 minutes to run, depending on how the net is doing.
The problem is that it doesn't display anything until all the processing is done, and then it hits you with it all at the end.
What I'd like to do is give updates, then clear the screen and show the final product...
as an additional challenge, I'd like to be able to have numbers change, or a scroll bar, or something to indicate status, eg: 10% done, 20 % done...
anyone know how I can do any of this? |
_________________ LWD web-cams: http://lwdcam.codecoma.com/?lwdcam
----
---
[9:08pm][09/16/2005]«+ flip » college...what is that
[9:08pm][09/16/2005]«+ Aff » apparently a place where you find rum
---
I used to live in my own little world, but they didn't like me there either.
You see dead people? I'm a software engineer, I don't see anybody!
---
My Amazon Wishlist
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Feb 18, 2003 6:45 am Post subject: |
|
PHP is open source isn't it? Rip it apart and customize it yourself, and then build it as a cgi module or a brand new apache plug-in. But otherwise, that's just the nature of the beast. |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
Webster
Guide Dog


Joined: 16 Feb 2002 Age: 28 Posts: 8701
Location: Vacationland
|
Posted:
Tue Feb 18, 2003 6:55 am Post subject: Re: display output before php code ends... |
|
I think that there's a way to clear the buffer as it goes along, correct? I'd have to look it up for the syntax, haven't done PHP for some 6-8 months or so. Depending upon the type of output you are creating, you could have it begin creating the page and display results as it goes along, such as with a long list of items, or you could just output some sort of status and then display it all at the end. You could use a div with an id/name tag and use javascript to hide your results output as you go along to keep the page clean (yeah yeah, it's a hack job, but its easy) |
_________________ www .Run To Win.com
The Marathon Thread
I finally published my book: Comprehensive Guide to Marathon Preparation & Recovery
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Feb 18, 2003 9:19 am Post subject: |
|
You're right. A quick peek at the PHP manual and I found this:
The flush function
Quote:Note: flush() has no effect on the buffering scheme of your webserver or the browser on the client side.
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.
Even the browser may buffer its input before displaying it. Netscape, for example, buffers text until it receives an end-of-line or the beginning of a tag, and it won't render tables until the </table> tag of the outermost table is seen.
Some versions of Microsoft Internet Explorer will only start to display the page after they have received 256 bytes of output, so you may need to send extra whitespace before flushing to get those browsers to display the page.
|
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
random
Moderator


Joined: 30 Oct 2000 Posts: 3382
Location: Left Field
|
Posted:
Tue Feb 18, 2003 1:56 pm Post subject: |
|
How well do you know the Ming libraries?
This is just a theory but maybe you can use ming to create a flash graphic that will display the progress. If you get that far it shouldn't be too much more difficult to display some data while in the process.
I just started playing with ming so i ain't sure that will work. |
_________________ Democracy substitutes election by the incompetent many for appointment by the corrupt few. -George Bernard Shaw
function video() {
die("radio star");
}
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Feb 18, 2003 2:41 pm Post subject: |
|
How about frames? The PHP code in one frame, an HTML page in another that would update in intervals. Actually the second frame can also be a PHP to access server side resources, and the first script would have to output progress into a shared data source. |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
Fido
Big Dog


Joined: 18 Oct 2000 Posts: 4410
|
Posted:
Tue Feb 18, 2003 4:03 pm Post subject: |
|
I used some code recently that did what you're asking. I think they broke down the processing into sections though, and used META REFRESH functions to update the page as it went along. From what I can tell, here is the section of code that does this. Might help you a bit, at least in theory.
//
// Search tables regeneration
//
case 'searchfill':
$step = (!empty($_GET['step'])) ? $_GET['step'] : '';
if ($step == 'cancel')
{
if (empty($convert_settings['board_disable']))
{
save_config('board_disable', 0);
}
else
{
unset($convert_settings['board_disable']);
save_config('convert_settings', $convert_settings);
}
message_die(GENERAL_MESSAGE, $lang['Indexing_stop_explain'] . $return_convert . $return_index);
}
if (!isset($_GET['start']))
{
if ($step == 'remove_common')
{
$percentage = 20;
$sql = 'SELECT COUNT(*) AS total FROM ' . POSTS_TEXT_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$common_threshold = floor(($row['total'] * $percentage) / 100);
$sql = 'SELECT MIN(word_id) AS min_id, MAX(word_id) AS max_id FROM ' . SEARCH_WORD_TABLE ;
}
else
{
$sql = 'SELECT MIN(post_id) AS min_id, MAX(post_id) AS max_id FROM ' . POSTS_TEXT_TABLE;
}
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$start = $row['min_id'];
$max = $row['max_id'];
}
else
{
if ($step == 'remove_common')
{
$common_threshold = $_GET['threshold'];
}
$start = intval($_GET['start']);
$max = $_GET['max'];
}
switch ($step)
{
//
// Step 4: remove common words
//
case 'remove_common':
while (still_on_time() && ($start <= $max))
{
$end = $start + 500;
$sql = 'SELECT word_id, COUNT(*) AS total'
. ' FROM ' . SEARCH_MATCH_TABLE
. ' WHERE word_id BETWEEN ' . $start . ' AND ' . $end
. ' GROUP BY word_id'
. ' HAVING total > ' . $common_threshold;
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not retrieve common words.', '', __LINE__, __FILE__, $sql);
}
$word_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$word_ids[] = $row['word_id'];
}
if (count($word_ids))
{
$sql = 'UPDATE ' . SEARCH_WORD_TABLE
. ' SET word_common = 1'
. ' WHERE word_id IN (' . implode(', ', $word_ids) . ')';
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not mark common words.', '', __LINE__, __FILE__, $sql);
}
$sql = 'DELETE FROM ' . SEARCH_MATCH_TABLE
. ' WHERE word_id IN (' . implode(', ', $word_ids) . ')';
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete common words.', '', __LINE__, __FILE__, $sql);
}
}
$start = $end + 1;
}
if ($end >= $max)
{
if (empty($convert_settings['board_disable']))
{
save_config('board_disable', 0);
}
else
{
unset($convert_settings['board_disable']);
save_config('convert_settings', $convert_settings);
}
$convert_settings['searchfill_lock'] = TRUE;
save_config('convert_settings', $convert_settings);
message_die(GENERAL_MESSAGE, $lang['Indexing_finished_explain'] . $return_convert . $return_index);
}
$percentage = (($max / $end) == 0) ? 0 : floor(100 / ($max / $end));
$msg = sprintf($lang['Step_percent_completed'], 3, 3, $percentage);
$url = 'index.' . $phpEx . '?mode=searchfill&step=remove_common&threshold=' . $common_threshold . '&max=' . $max . '&start=' . $start;
meta_refresh($url);
message_die(GENERAL_MESSAGE, $msg . $stop_indexing_link);
break;
|
|
|
|
|
|
|
|
|
|
|
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB
© 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours
Help us keep advertisements off this site. Donate today!
|
|