i hope u can help me guys ♥ (PHP - MySQL - HTML5 - CSS3) I'm trying to do (disabled for previous link) and active states class on pagination i need something like this:
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active" aria-current="page">
<a class="page-link" href="#">2</a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
i need to do it with this code:
<?php
$query = "SELECT * FROM categories";
$result = mysqli_query($conn, $query);
$total_cat = mysqli_num_rows($result);
$total_pages = ceil($total_cat / $limit);
?>
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="categories.php?page=<?php if (($page - 1) > 0) {
echo $page - 1;
} else {
echo 1;
}
?>">Previous</a></li>
<?php
for ($i = 1; $i <= $total_pages; $i++) {
?>
<li class="page-item"><a class="page-link" href="categories.php?page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php
}
?>
<li class="page-item"><a class="page-link" href="categories.php?page=<?php
if (($page + 1) < $total_pages) {
echo $page + 1;
} elseif (($page + 1) >= $total_pages) {
echo $total_pages;
}
?>">Next</a></li>
</ul>
</nav>
source https://stackoverflow.com/questions/67941675/how-do-disabled-for-previous-link-and-active-states-class-on-pagination
No comments:
Post a Comment