Maria, If you simply have a table with an id field that has the auto-increment attribute (field is int(10)) then you can get the current id and go from there. To get the current ID of a record you just created, you can use the mysql_insert_id($link) function in PHP, or the MySQL equivalent. Remember that mysql_insert_id can only be used after an INSERT and before a COMMIT.
Of course, my advice assumes that each related message is stored in id sequence. If it is not, then your application might have to assign a unique sequential id (in addition to the id field I mentioned above) that associates the messages together as a group. Then you can construct an appropriate query to extract just what you need. I hope this helps. I am certain that you will have many other offers with advice for you that may be different than mine. I am an old database programmer and so think in those terms often, not like a SQL designer! Hugs, Mark Richards -----Original Message----- From: Maria Garcia Suarez [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 09, 2003 11:53 To: [EMAIL PROTECTED] Subject: How to get previous and next result 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 __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]