Jump to content

Replacing an output with an updated output on an infinate loop


victorianrider

Recommended Posts

Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script:

 

<?PHP

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

$RepeatIt = -1;

for($g=1; $g!=$RepeatIt+1; $g++)

{

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

 

$ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>";

echo $ScanMessage;

 

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

***PROCESSING AND SCAN CODE***

}

?>

 

At the moment it's returning:

 

:.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.:

 

:.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.:

 

:.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.:

 

:.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.:

 

So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line.

 

Any suggestions?

 

Thanks.

Link to comment
Share on other sites

I don't think it possible without refreshing the page (which you probably don't want).

 

Once data is sent to the browser from the script, its up to the browser to do something with it (meaning its out of PHP's hands).

 

I've got an idea, but I don't think its very efficient and may not work as intended due to several factors affecting 'flush()'. 

Have your script echo '<div>content here</div>' and flush() it to the browser, and setup an interval in js to remove "old" div elements from a container.

Link to comment
Share on other sites

I don't think it possible without refreshing the page (which you probably don't want).

 

Once data is sent to the browser from the script, its up to the browser to do something with it (meaning its out of PHP's hands).

 

I've got an idea, but I don't think its very efficient and may not work as intended due to several factors affecting 'flush()'. 

Have your script echo '<div>content here</div>' and flush() it to the browser, and setup an interval in js to remove "old" div elements from a container.

Thanks I'll try something like that. Cheers mate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.