| re: Mysql: next and previous
On Tue, 2 Nov 2004 13:55:20 +0100, "Bob Bedford"
<bedford1@YouKnowWhatToDoHerehotmail.com> wrote:
[color=blue]
>Does exist a next prev function in PHP/Mysql. I've a website with returns
>lot of records (say about 200). The user may browse trough the list or
>returned records, but he has to click the record result then click back's
>browser in order to see the next record. I'd like to provide a "see next"
>and "see previous" record in the details itself. How to do so ?
>
>Bob
>[/color]
You can specify the number of records retured and the offset in the
MySQL query. So, for instance, if you wanted ten records at a time you
could do something like:
SELECT * FROM table WHERE condition ORDER BY field LIMIT 10,$x
where $x is the offset, then make the back/next links increment or
decrement the value of $x
BTW, I can never remember off the top of my head which order the LIMIT
clause goes in, so it might be as above, or it might be LIMIT $x,10
hth
C |