I am trying to set a condition for php- mysql pagination so that it can change the current page "li" to "li class="active" " to mark the current selected page. I am new to php and searching for such pagination tutorial but no luck.
I have done so far what is working but not able to mark selected page. Here $id is for detecting the current page id. How can I set if condition ( or other) so that I can mark the current page item in the pagination? Thousands thanks for helping me.
<ul class="pagination">
<?php if($id > 1) {?> <li><a href="?id=<?php echo ($id-1) ?>">Previous</a></li><?php }?>
<?php
for($i=1;$i <= $page;$i++){
?>
<?php
if ($id>1)
{ ?>
<li class="active"><a href="?id=<?php echo $i ?>"><?php echo $i;?></a></li>
<?php }
?>
<!-- <li><a href="?id=<?php echo $i ?>"><?php echo $i;?></a></li> -->
<?php
}
?>
<?php if($id!=$page)
//3!=4
{?>
<li><a href="?id=<?php echo ($id+1); ?>">Next</a></li>
<?php }?>
</ul>