Search code examples
phpmysqlchatroom

chat rooms implementation


Can you give me an idea on how to implement chat room using PHP and MySQL?


Solution

  • You will probably want to use AJAX or if not that, Javascript with timer to make chat appear instant or with polled updates.

    1. (Chat text data fetched and displayed.) Form frontend fields accepts chat input
    2. Chat input sent to server via form. AJAX waits to receive data to update chat text display.
    3. Server updates a data queue (example - PHP dumps to MySQL). Data sent back to frontend via AJAX wrappers
    4. Repeat

    There are lots of tutorials on creating something like this - including a number with AJAX i/o - http://css-tricks.com/chat2/