upp Posted November 25, 2010 Share Posted November 25, 2010 I need some advice, I'm not sure if this is the right section to post this or not but I'll give it a try. I am creating a website for a small group of people to be able to message back and forth. I ran into a problem when doing the whole reply to a message option. I dont want to have each individual message as a new entry in my database, and then look for each message in that conversation when loading the conversation, I thought about inserting something like +=+=+=+=+=+= in between messages in the conversation so that when i pull up that conversation i could just separate the messages into an array by looking for that +=+=+=+=+=+= in the string of text and separating all the messages out. I want to know if anyone knows a better way of doing this or if this is a good way to go. thanks for any suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/219806-storing-multiple-message-in-database/ Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 Why would you want to do that? Storing each entry as its own record is the proper way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/219806-storing-multiple-message-in-database/#findComment-1139529 Share on other sites More sharing options...
laffin Posted November 25, 2010 Share Posted November 25, 2010 I have to agree with Pikachu on this, keep each msg seperate, add a replythread to field and a loop which gets the the previous messages. Pretty simple pseudo code. $replythread=$msg['replythread) while(!empty($msg['replythread']) { $next_msg=get_msg($replythread); if(!empty($next_msg)) { $msg['body'].="+++++\n".$next_msg['body']; $replythread=$next_msg['replythread']; } else $replythread=0; } [/code] another option is to store all the ids into replythread (as a string) About the only bad thing of this method is that the field should be large enough to hold a very long list of ids. pseudo code. [/code] $replythread=explode(',',$msg['replythread']) foreach($replythread as $thread) { $next_msg=get_msg($thread); $msg['body'].="+++++\n".$next_msg['body']; $replythread=$next_msg['replythread']; } [/code] Quote Link to comment https://forums.phpfreaks.com/topic/219806-storing-multiple-message-in-database/#findComment-1139544 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.