Maria, Maria Garcia Suarez sagte: > Hi there! > > I'm currently developing a web where we let users > create their own forums. All the messages (wherever > they are posted) are stored in the same mysql table. > > When users read a certain message I would like to > display the previous and next message in that forum. > > Since all the messages (of the different forums) are > stored in the very same table I don't find how to > guess what's the ID of the previous and next message. > > Is there any way to find those IDs? > > Thanks. > > Kisses, > Maria >
What I do is that I assign each message its ID (of course) plus its parent_ID in case of a reply (zero in case of thread-starting message) plus a thread_ID which is equal to the ID of the message which started the thread. Then I select all messages with the same thread_ID. There I have the messages that belong to one thread. I store the unique ID's in an array which I use to link to the next / previous message. You might want to assign each message a forum_ID, too. Did I get the idea across? If you are interested I can look for some code later. (Don't have any here at work) Let me know. Cheers, Sebastian -- Once a problem is defined - it is half way solved. (Henry Ford) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]