> [snip] > I have a chat script. I want it to refresh the chat > display area > whenever there is a new message posted, but not > every 10 seconds or so. > How could I get the script to refresh only when > there is a new entry > into the database table? > [/snip] I have implemented something along these lines for an online chess game (so the board would only refresh when the other player moves). It did require a loop, as suggested. I used a hidden IFRAME to check the data. Basically, I would refresh the page referred to by the IFRAME every 10 seconds or so, and this page contained JavaScript that invoked a function on the containing page. The JavaScript function on the containing page would then refresh the page when the parameter passed to it indicated that the other player had moved. I did implement the site using PHP, but this really isn't a PHP specific approach.
I imagine you would do something very similar for chat (in fact, I had been considering implementing it for the online chess site so that the users could send messages to each other during the course of the game). And there is a performance issue if you are going to support a lot of users at one time; however, at least it is not as bad as refreshing the entire page every 10 seconds (this would be particularly disastrous for my chess board, which contained many images). There are a number of references that talk about this trick if you search on "iframe rpc javascript" in google: http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=iframe+rpc+javascript You will still get the clicking, tho. But users' can disable it if it annoys them -- sometimes it is nice to know that something is going on. Hope this helps. Jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php