smartin1017 Posted November 16, 2008 Share Posted November 16, 2008 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 https://forums.phpfreaks.com/topic/132905-messaging-system/ Share on other sites More sharing options...
marcus Posted November 16, 2008 Share Posted November 16, 2008 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 https://forums.phpfreaks.com/topic/132905-messaging-system/#findComment-691106 Share on other sites More sharing options...
smartin1017 Posted November 16, 2008 Author Share Posted November 16, 2008 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 https://forums.phpfreaks.com/topic/132905-messaging-system/#findComment-691111 Share on other sites More sharing options...
marcus Posted November 16, 2008 Share Posted November 16, 2008 Well if you were to send multiple messages as once you could just do something like <?php $to = $_POST['to']; $e = explode(";",$to); foreach($e AS $f){ if(is_user($f)){ // fake function // insert a message for everybody } } ?> Link to comment https://forums.phpfreaks.com/topic/132905-messaging-system/#findComment-691112 Share on other sites More sharing options...
smartin1017 Posted November 16, 2008 Author Share Posted November 16, 2008 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 https://forums.phpfreaks.com/topic/132905-messaging-system/#findComment-691117 Share on other sites More sharing options...
marcus Posted November 16, 2008 Share Posted November 16, 2008 Um, the foreach statement splits each of the usernames into a new "variable" which then would create a new row for each of the member (hence for each) Link to comment https://forums.phpfreaks.com/topic/132905-messaging-system/#findComment-691130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.