p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: re: load HTML first, then run PHP script


Message #1 on Mon, 21 Oct 2002 12:43:59
Hi,


Recently, I wrote PHP script for checking MSN Messnger online status, and
displaying results on the webpage.

It take same time for the script to connect to MSN server
and display results, sometimes up to seconds.

I would like to load HTML page first, and then show some info
that script is checking for status, so users can view the rest
of the html page while status is recieved.

Is it possible to this somehow in the background, like background
process, or to preload html first and disply that.

Message #2 on Mon, 21 Oct 2002 15:58:08 +0200
http://www.php.net/manual/en/function.flush.php

Regards.

-----Original Message-----
Sent: maandag 21 oktober 2002 12:44
To: beginning php
Subject: [beginning_php] re: load HTML first, then run PHP script


Hi,


Recently, I wrote PHP script for checking MSN Messnger online status,
and displaying results on the webpage.

It take same time for the script to connect to MSN server
and display results, sometimes up to seconds.

I would like to load HTML page first, and then show some info that
script is checking for status, so users can view the rest of the html
page while status is recieved.

Is it possible to this somehow in the background, like background
process, or to preload html first and disply that.

Thanx

---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to
%%email.unsub%%.


Message #3 by on Mon, 21 Oct 2002 13:39:13 -0700
Flush() might not have the intended effect because of browser caching.  The
client browser might get the text you flushed from the server, but might not
feel that there is enough yet to start rendering and displaying the page.

If you want to use two different page requests, you can set a simple flag in a
session variable to keep track of whether or not you've displayed the status
message.

If the flag is false or is not set, then you haven't shown the status message.
Show the message, set the session flag, and reload the page.

If the flag is set, then run the rest of your script.

<?php
session_start();

if(!isset($_SESSION['showed_msg']) || ($_SESSION['showed_msg'] !== true))
{
   echo "<HTML>\n";
   echo "<HEAD><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"1\"></HEAD>\n";
   echo "<BODY>Query in progress, please wait...</BODY>\n";
   echo "</HTML>\n";
   $_SESSION['showed_msg'] = true;
   exit()
}

// run your MSN status query here.

?>

Message #4 on Thu, 24 Oct 2002 23:42:39
Oh,

i forgot to tell that I am looking for the solution that will run on the 
Windows 2000 Server.

I am aware of the flush()

It is well known issue that it's not performing same flush() as it should 
and as it does on UNIX systems.

So, any other ideas ?



  Return to Index