Re: How to get previous and next result

2003-09-11 Thread Sebastian Haag
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 mes

RE: How to get previous and next result

2003-09-09 Thread Dan Greene
Having developed such an app myself (albeit in Oracle where the wonder of 'connect by' exists which according to 'to-do' lists is coming for MySQL yippie!), this is what I recommend... 1- if your forum is 'threaded', i.e. a message is in response to another, you can use that linking to get

RE: How to get previous and next result

2003-09-09 Thread Maria Garcia Suarez
Hi there! --- Christopher Knight <[EMAIL PROTECTED]> wrote: > next: > select cols from table where id > YOUROLDID and > forums = CURRENT_FORUM order by id limit 1 > previous: > select cols from table where id < YOUROLDID and > forums = CURRENT_FORUM order by id desc limit 1 Thanks for your answer

RE: How to get previous and next result

2003-09-09 Thread Christopher Knight
next: select cols from table where id > YOUROLDID and forums = CURRENT_FORUM order by id limit 1 previous: select cols from table where id < YOUROLDID and forums = CURRENT_FORUM order by id desc limit 1 however, this may not be as fast or efficient enough ou might want to create another id field

RE: How to get previous and next result

2003-09-09 Thread Mark Richards
esday, September 09, 2003 12:35 To: Mark Richards; [EMAIL PROTECTED] Subject: RE: How to get previous and next result Hi there! --- Mark Richards <[EMAIL PROTECTED]> wrote: > If you simply have a table with an id field that has > the auto-increment > attribute (field is int(10))

RE: How to get previous and next result

2003-09-09 Thread Maria Garcia Suarez
Hi there! --- Mark Richards <[EMAIL PROTECTED]> wrote: > 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_in

RE: How to get previous and next result

2003-09-09 Thread Mark Richards
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. Reme