The pagination here works fine, but addition to pagination, as the limit per page is 3 suppose total 8 items in database so i want to display " showing 1 t0 3 item of 8" on page one, "showing 4 to 6 items of 8" on page two and so on. please help
$recordsLimit = 3;
$page = isset($_GET['page']) ? intval($_GET['page']): 1;
$totalProducts = countProducts($selectedCategoryId);
$totalPages = ceil($totalProducts / $recordsLimit);
$pageNumber = $recordsLimit * ($page - 1);
$products = getProductsByCatId($selectedCategoryId, $pageNumber, $recordsLimit);
<?php if($totalProducts > $recordsLimit) : ?>
<div class="pagination">
<span>Page <?php echo $page.' of '.$totalPages; ?></span>
<?php for($i=1; $i <= $totalPages; $i++) :
if($i == $page) { ?>
<strong><?php echo $i; ?></strong>
<?php } else { ?>
<a href="products.php?cat_id=<?php echo $selectedCategoryId; ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a>
<?php }
endfor; ?>
<?php endif; ?>