Good night, I need a pagination made in PHP and PostgreSQL , I searched the internet but did not find anything useful, I tried to apply a PHP / MySQL code but the result was negative.
The code I used:
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 5;
$query = pg_query($dbconn,"select * from my table limit 5 offset $start_from") or die(pg_result_error($dbconn));
$total_query = pg_num_rows($query);
$total_pages = ceil($total_query / 5);
Buttons and Links:
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='index.php?page=".$i."' class=\"textPagina\">".$i."</a> ";
}