Michiel van Heusden wrote:
i understand what you say i was just wondering whether there's an option of just keeping the html open and printing it to the end. like <html> <head></head> <body> <p> <font etc..> <? // start loop //request messages // output to html //loop ?>
----- Original Message ----- From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "Michiel van Heusden" <[EMAIL PROTECTED]>; "PHP" <[EMAIL PROTECTED]> Sent: Thursday, March 06, 2003 12:52 PM Subject: Re: [PHP] some help needed building chat-app
any,You should understand the concept of php better. The browser request the page, php script prints the messages and closes the conection, the page is displayed. You cannot continue printing out after the conection is closed. So you need to tell the browser to refresh after certain amount of time to get a fresh copy with new messages.
Michiel van Heusden wrote:
actually it's not as much about refreshing the whole page
it's just about refreshing the chat-messages that have been posted
so i need some sort of loop that continually seeks for new data and if
LIMITprints them
thanks anyway
----- Original Message ----- From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "Michiel van Heusden" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, March 06, 2003 11:00 AM Subject: Re: [PHP] some help needed building chat-app
If you mean making the client refresh the page after an amount of time,use
lookingheader('Refresh: 10'); it is in seconds
Michiel van Heusden wrote:
thanks for your replies
the other thing i was trying to ask :) is how to keep on looping and
for new messages is just a plain loop ok or should i use a timer or whatsoever, i have no clue
right now it's a bit like
$x = "loop";
do while ($x == "loop") { //mysql_query (select new messages) //output new messages to bottom of html }
"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
You need only one query with LIMIT, example:
//this will select last 10 messages
$res=mysq_query('SELECT * FROM chat_messages ORDER BY addtime DESC
datathis10');
// this will print them from newer to older while($message=mysql_fetch_array($res)) { echo $message['from'].': '.$message[message'].'<br>'; }
the connection is closed once your script is over (unless you use pconnect), you can not really find out the window has been closed.
you don't need to worry about any crash, sql server will take care of
Michiel van Heusden wrote:
i'm working on a chat-app which has to be extremely plain and simple mysql is available
i tried stripping some of the big scripts, but ended up in a mess so i've ended up building a little app myself
i'm just wondering whether i'm using the right principe to get the
againrefreshed in the chat..
i'm dropping all the messages as records in a mysql-table then i have the php script
first printing all the html>>> stuff opening a paragraph
and then a loop, querying the mysql, printing the data and querying
closesis that a way to build this, or are there much better ways?
and some other questions: * how can i make sure the db-connection is closed before the user
andthe
window? * is there any server-side problem with this (say, 100 people log on,
are contineously querying mysql, won't there be some sort of crash?)
thanx a lot michiel
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php