Reputation: 53
I have learned pagination from the link How to set condition in following code for marking current page in pagination?
using code
<?php
$id=3; // test value
$page=20; // test value
$li=array(); // temporary array for convenience
$template='<li%s><a href="?id=%s">%s</a></li>';
if($id>1) $li[]=sprintf($template,'',$id-1,'Previous');
for($i=1;$i<=$page;$i++) {
if($i==$id) $li[]=sprintf($template,' class="active"',$i,$i); // Current
else $li[]=sprintf($template,'',$i,$i);
}
if($id<$page) $li[]=sprintf($template,'',$id+1,'Next');
$li=implode('',$li); // convert to string for printing
?>
<ul class="pagination">
<?php print $li; ?>
</ul>
But it is showing data after reloading data? is there any way to make it show without reloading page? I am new to pagination - please help.
Upvotes: 3
Views: 7934
Reputation: 164
You can use pagination without page load by ajax or jQuery. Please read the example following the link below - https://datatables.net/examples/basic_init/alt_pagination.html
Upvotes: 4