How do I echo the three dots "..." after a specific number (e.g., 9) and echo the last two numbers after the three dots "..." (e.g., 57 and 58) for pagination using MySQLi and PHP?
Here's the code:
<?php
$output = "";
$tpages = ceil($engine->numrows("SELECT null FROM `cms_articles_comments` WHERE `article_id` = '" . $id . "'") / 10);
if ($page == 1)
{
$output .= '<button type="button" class="btn btn-info pull-left goToTop" disabled><i class="fa fa-arrow-left"></i> Previous</button>';
}
else
{
$output .= '<a href="/articles/' . $seo . '&p=' . ($page - 1) . '#comments" ng-click="progress()" class="btn btn-info pull-left goToTop"><i class="fa fa-arrow-left"></i> Previous</a>';
}
if ($page >= $tpages)
{
$output .= '<button type="button" class="btn btn-info pull-right goToTop" disabled>Next <i class="fa fa-arrow-right"></i></button>';
}
else
{
$output .= '<a href="/articles/' . $seo . '&p=' . ($page + 1) . '#comments" ng-click="progress()" class="btn btn-info pull-right goToTop">Next <i class="fa fa-arrow-right"></i></a>';
}
$output .= '<div class="fpagination fpagination-centered"><ul>';
for($i = 1; $i <= $tpages; $i++)
{
if ($i == $page)
{
$output .= '<li class="active"><a href="/articles/' . $seo . '&p=' . $i . '#comments" ng-click="progress()" class="goToTop">' . $i . '</a></li>';
}
else
{
$output .= '<li><a href="/articles/' . $seo . '&p=' . $i . '#comments" ng-click="progress()" class="goToTop">' . $i . '</a></li>';
}
}
$output .= '</ul></div>';
echo $output;
?>
With the code provided above, I get this:
I want the pagination list to show like this:
prntscr.com/a0azua, prntscr.com/a0ay1s
Thanks in advance.