limiting the amount of data to be show on one page.
| From: | CrossWalkCentral | Date: | Sun, 26 May 2002 06:03:40 +0000 |
| Subject: | limiting the amount of data to be show on one page. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-19432@lists.php.net to get a copy of this message | ||
If I want to use the bellow liste senario.
How would i go about setting up the 1 2 3 4 5 6 7 8
page #'s how would I know when to stop counting?
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
time.
J
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 www.mysql.com for more information about using LIMIT in your
> queries.
>
> -Kevin