Project

General

Profile

Bug #2357

Feature #2355: implement pagination

prev/next buttons are displayed on a table that has 100 entries

Added by Andrii Arsirii 8 months ago. Updated 8 months ago.

Status:
Новый
Priority:
Нормальный
Assignee:
-
Start date:
03/26/2018
Due date:
% Done:

0%


Description

...while it shouldn't.
Because on pressing next button user gets empty list

History

#1 Updated by Andrii Arsirii 8 months ago

https://stackoverflow.com/questions/818567/mysql-pagination-without-double-querying

I almost never do two queries.

Simply return one more row than is needed, only display 10 on the page, and if there are more than are displayed, display a "Next" button.

SELECT x, y, z FROM `table` WHERE `some_condition` LIMIT 0, 11

// iterate through and display 10 rows.

// if there were 11 rows, display a "Next" button.

Your query should return in an order of most relevant first. Chances are, most people aren't going to care about going to page 236 out of 412.

When you do a google search, and your results aren't on the first page, you likely go to page two, not nine.

Good idea, solves problem, and no speed impact.

Also available in: Atom PDF