I made the pagination available in the code below, following an example here of the stack, but it does not work as I need it to: display a maximum of 5 records per page and thus create the other pages. This code counts all the records of the table, let's say it is 8, from this it creates 8 pages and 8 blocks of pages, which would fit 5 in one and 3 in another. I accept suggestions on how to adjust.
$page = (isset($_GET['pagina'])) ? (int)$_GET['pagina'] : 1;
$limit = 5;
$offset = ($page * $limit) - $limit;
$sql = "SELECT * FROM registros LIMIT $limit OFFSET $offset";
$resp = mysqli_query($conexao, $sql);
$res = mysqli_fetch_assoc($resp);
$sql2 = "SELECT count(*) as count FROM registros";
$resultado = mysqli_query($conexao, $sql2);
$row = mysqli_fetch_assoc($resultado);
$total_de_paginas = $row['count'];
echo '<div>
<ul class="pagination pagination-sm pull-right">
<li><a href="#" id="anterior"><<</a></li>';
for($i = 1; $i <= $total_de_paginas; $i++){ ?>
<li><a href="?<?php echo http_build_query(array('page' => $i)) ?>"><?php echo $i ?></a></li>
<?php }
echo '<li><a href="#" id="próxima">>></a></li>
</ul>
</div> ';