Jump to content

Messaging system


smartin1017

Recommended Posts

Hi guys,

 

I am at the tail end of a big site I am building and am trying to figure the best way to accomplish the messaging system. Basically it will act like the standard social network system. You click 'send message' on someones profile, go to a page that has a title field and a text field, enter your message and press sybmit. This is where I need some guidence. I figure to have a thread table and have the fields id (autoincrement message id), to id, from id, message, timestamp. I need it to act like a conversation. Someone writes and sends, the person gets an alert saying they have a message and looks at it, they then reply, the first person then gets a message and it says on the message page the message with a (replied) or (unread), i want them to be able to go to their message page and see what they have replied to and whats new. Basically a conversation where the newest one always appears on top. Also, I feel there is a much more eficient way of doing the database table. Any advice?

Link to comment
Share on other sites

When creating this keep in mind all the fields.

 

Your PM table should be set up something like this:

id - int(11) - primary key - auto_increment

to - int(11)

from - int(11)

subject - varchar(64)

message - text

status - int(1)

date - varchar(64)

time - int(24)

 

status would be used to define the viewership of it, Unread, Read, Replied, so 0 = Unread, 1 = Read, 2 = Replied

 

When viewing the inbox you just have to know how you want it set up.

 

-Subject- / -From- / -Date Sent- / -Status- / -Delete-

 

And selecting the messages

 

$sql = "SELECT * FROM `pm_table` WHERE `to`='".$_SESSION['uid']."' ORDER BY time DESC LIMIT 15";

 

and you could probably go about from there on your own

 

Link to comment
Share on other sites

Thats is kind of what I was thinking but some things came to mind, in the query WHERE part you reference to, what if that same person is a from from a different message, this is wher I start getting confused. One user could have several messages going at once, so they could be a 'from' or a 'to', I was thinking of using two tables, one with a unique thread id, to and from, and the other with that id passed to it then an auto incrememnt msg_id and everything else you states, I still dont know if this will work. What are your thoughts?

Link to comment
Share on other sites

So your saying to store all the messages in one field and seperate by semicolon, I am thinking different rows with a timestamp all attached to the same msg thread id, thus the two tables, but everytime I start I get stumped part way through. Keep in mind, one person can have multiple different messages at once with different users, the individual conversation will be in descending order going down the page.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.