You should also add an ORDER BY clause in there, as the SQL standard doesn't 
guarantee the order that rows are retrieved in. There's a chance that 
you'll get, say, 20 rows on the first page, go to the second page and get 
some of the rows you've already seen on the first page. If you use an ORDER 
BY, you'll at least guarantee that you'll get them in the same order each 


Kevin Stone wrote:

> $query = "SELECT * FROM mytable LIMIT $i, 20";
> Where 20 is the number of rows to retrieve and $i is the starting row.
> By incrementing $i + 20 you can do next, prev buttons, or parse the total
> number of rows into page links (prev - 1, 2, 3, 4, 5, 6.. 10.. 20 - next).
> Search for more information about using LIMIT in your
> queries.
> -Kevin

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to