Hello,I have a problem with pagination,what’s happening,first category posts works great but, others categories when i click on second page bring me back again to the first category second page…anyone who can help with this
I appreciate that…tnx
this is my code
<?php
if(isset($_GET['category'])) {
$post_category_id = $_GET['category'];
}
$per_page = 30;
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "";
}
if($page == "" || $page == 1) {
$page_1 = 0;
} else {
$page_1 = ($page * $per_page) - $per_page;
}
$find_count = mysqli_query($connection,$post_query_count);
$count = mysqli_num_rows($find_count);
if($count < 1) {
echo "<h1 class='text-center'>No posts available</h1>";
} else {
$count = ceil($count /$per_page);
$query = "SELECT * FROM posts WHERE post_category_id = $post_category_id ORDER BY post_id DESC LIMIT $page_1, $per_page";
$select_all_posts_query = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_all_posts_query)) {
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_title_head = $row['post_title_head'];
$post_image = $row['post_image'];
$post_status = $row['post_status'];
?>
<div class="col-sm-6 col-md-3 isotope-item web-design">
<div class="image-box">
<div class="overlay-container">
<a href="post.php?p_id=<?php echo $post_id; ?>">
<img class="img-rensposive" src="images/<?php echo $post_image; ?>" alt="Image">
</a>
<a href="post.php?p_id=<?php echo $post_id; ?>" class="overlay small">
<i class="fa fa-link"></i>
<span><?php echo $post_title_head ?></span>
</a>
</div>
<a href="post.php?p_id=<?php echo $post_id; ?>" class="btn btn-light-gray btn-block">
<?php echo $post_title ?>
</a>
</div>
</div>
<?php } }?>
</div>
</div>
<ul class="pagination">
<?php
$number_list = array();
for($i =1; $i <= $count; $i++) {
if($i == $page) {
echo "<li '><a class='active_link' href='category.php?page={$i}'>{$i}</a></li>";
} else {
echo "<li '><a href='category.php?page={$i}'>{$i}</a></li>";
}
}
?>
</ul>
</div>
</section>