I am working on a pagination feature in a web service I am writing, but my lack of math insight is killing me now.
I have a couple of keys: totalItems, cu
If you work with mysql its
LIMIT offset, items_per_page
To calculate the offset u can use
$offset = ($page - 1) * $items_per_page;
Then replace the $page accordingly.
Last
$last_offset = ($totalPages - 1) * $items_per_page;
Previous
$previous_offset = (($currentPage - 1) - 1) * $items_per_page;
Next
$next_offset = (($currentPage + 1) - 1) * $items_per_page;
EDIT :
if ($previous_offset > 0) echo 'prev';