You can specify the offset in the LIMIT clause:
LIMIT 0, 10 LIMIT 10, 10 LIMIT 20, 10 ...
Therefore, when creating a LIMIT clause, your code should look like this:
$offset = ($current_page - 1) * $items_per_page; $sql = "[...] LIMIT $offset, $items_per_page";
Of course, you need to make sure $current_page - >= 1 . But this is easy to do:
$current_page = empty($_GET['current_page']) ? 1 : max(1, (int)$_GET['current_page']);
source share