if ($replies_count !== 0) {
$sql = "SELECT COUNT(*) FROM `phpc_topic_replies` WHERE `phpc_topic_serial`=$topic_serial";
$result = mysqli_query($coni,$sql) or trigger_error("SQL", E_USER_ERROR);
$r = mysqli_fetch_row($result);
$numrows = $r[0];
$rowsperpage = 15;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 2;
}
$offset = ($currentpage - 1) * $rowsperpage;
$get_replies = "SELECT * FROM `phpc_topic_replies` WHERE `phpc_topic_serial`=$topic_serial AND `phpc_reply_valid`='yes' order by phpc_reply_serial asc LIMIT $offset, $rowsperpage ";
$result = mysqli_query($coni,$get_replies);
while ($rep = mysqli_fetch_assoc($result)) {
$reply_serial = $rep['phpc_reply_serial'];
?>
<div>
<h4>echo whatevr is gonna be paginted here like this "?php echo new ??</h4>
</div>
<?php
}
$range = 2;
echo '<div class="row"> <h3 class="center"> Read more replies </h3> <ul style="text-align: center;" class="pagination">';
if ($currentpage > 1) {
echo "<li> <a href='$main_url/read/$topic_url/1'>First Page</a></li> ";
$prevpage = $currentpage - 1;
echo "<li> <a href='$main_url/read/$topic_url/$prevpage'><</a> </li>";
}
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
echo "<li> <a href='#' class='active'>$x</a>";
} else {
echo "<li> <a href='$main_url/read/$topic_url/$x'>$x</a> </li> ";
}
}
}
if ($currentpage != $totalpages) {
$nextpage = $currentpage + 1;
echo "<li> <a href='$main_url/read/$topic_url/$nextpage'>></a></li> ";
echo "<li> <a href='$main_url/read/$topic_url/$totalpages'>Last Page</a></li> ";
}
}
echo '</ul></div>';
?>
preview:
http://i.imgur.com/xHEcoFp.jpg[
^]