thanks chitan for chat example.
i hope it will useful for beginners.
You don't need a DB to make a chat app, but it does help. One alternative would be to save new messages to a text file - not too nice.
The page loads some js that tells the page to run a script every 5 seconds.
The script accesses a php script and gets data from the chat DB.
The js script then updates the chat 'window' with the data from the php script.
Quite simple really. Of course, you have to handle new posts (update DB) too.
Writing a GOOD chat script is considerably more difficult.