954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Chat concept

Im thinking about taking on a chat room php based project. I want to make sure my logic is right though. This is very raw so please feel free to contribute if you see any problems that might occur.

MYSQL

TABLES
Username
chatroom1
chatroom2
etc..

PHP

Sign up.php
Insert username and password into Username table.

Login.php
Search Username table to validate username and password. Create session.

chatroom1.php
enter message into chatroom1 table. Retrieve messages periodically by new message entered organized by timestamp.

RazorRamon
Junior Poster in Training
74 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

hi
it is not understandable. i m not getting u. can u explain it in more detail.

hostingguru
Newbie Poster
4 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Ajax. For periodic calls to DB.

seems OK. Do you really need to create a chatroom table every time? Depends on your structure I suppose. Can users create their own chatrooms or are there a few that will be available to them?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

I wanted to have a fix number of rooms. I know Yahoo got in trouble a few years ago with the creation of new chat rooms by users on yahoo messenger. I know creating a new table isn't very difficult though.

I am very green when it comes to javascript and ajax. I'm a lil intimidated actually. I understand the concept of ajax but dont really understand on how to call a database with it in conjunction with php.

RazorRamon
Junior Poster in Training
74 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

You won't be able to make a chat for php without ajax.

If you use jQuery, it should be quite easy.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

You dont need to create a chatroom table everytime there is new chat launched. Ive never programmed a chatroom but I would guess the database would rather be two tables.
1st table for a chats with columsn for example: "id, created_by, launched, chat_title".
2nd table is all the comments with columns like, "idnumb, chatid_FK(referencing the 1st table and linking the id together), comment, user.
3rd table would then obviously be the users info like userid, username, password etc.

Then the ajax query queries the database with something like: "select chat_title, idnumb, comment, name from chat_table, comment_table, user_table where chat_table.id = '35' and userid = column_table.user offset 0 limit 20 order by idnumb desc

This would then fetch the last 20 comments, usernames for the comments, title of the chat.

FreddieBambino
Light Poster
37 posts since May 2010
Reputation Points: 12
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: