What best practices should be followed when creating a pagination system in PHP to avoid displaying duplicate entries on each page?

When creating a pagination system in PHP, it's important to ensure that each page displays unique entries and avoids duplicates. To achieve this, you can use SQL's LIMIT and OFFSET clauses to fetch a specific range of entries for each page.

// Assuming $page is the current page number and $limit is the number of entries per page
$offset = ($page - 1) * $limit;
$query = "SELECT * FROM entries LIMIT $limit OFFSET $offset";
// Execute the query and display the entries on the page