/ Published in: PHP
this can be adapted by simply changing the urls. starts with an array for incoming data.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Set the current page at 1 if it's not already set $per_page = 100; $clean_query_string = (isset($_GET['user_id'])) ? str_ireplace("p=".@$_GET['p']."&", "", $_SERVER['QUERY_STRING']) : str_ireplace("p=".@$_GET['p'], "", $_SERVER['QUERY_STRING']); if(substr($clean_query_string,-1)=="&"){$clean_query_string = substr_replace($clean_query_string, "", -1);} ?> <?php if($user->is_admin() && ($count_transactions > $per_page || isset($_GET['p'])) && $pages > 1):?> <div class="pagination"> <ul> <?php if($pages <= 12):?> <li class="prev <?php if($_GET['p']==1 || !isset($_GET['p'])):?>disabled<?php endif;?>"><?php if($_GET['p']==1 || !isset($_GET['p'])):?><a href="#">← Previous</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']-1;?>&<?php echo $clean_query_string;?>">← Previous</a><?php endif;?></li> <?php for($i=1;$i<=$pages;$i++):?> <li class="<?php if($i==$_GET['p']) echo "active";?>"><?php if($i!=$_GET['p']):?><a href="reports.php?p=<?php echo $i;?>&<?php echo $clean_query_string;?>"><?php echo $i;?></a><?php else:?><a href="#"><?php echo $i;?></a><?php endif;?></li> <?php endfor;?> <li class="next <?php if($_GET['p']==$pages):?>disabled<?php endif;?>"><?php if($_GET['p']==$pages):?><a href="#">Next →</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']+1;?>&<?php echo $clean_query_string;?>">Next →</a><?php endif;?></li> <?php else: ?> <?php if($current_page <= 5):?> <li class="prev <?php if($_GET['p']==1 || !isset($_GET['p'])):?>disabled<?php endif;?>"><?php if($_GET['p']==1 || !isset($_GET['p'])):?><a href="#">← Previous</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']-1;?>&<?php echo $clean_query_string;?>">← Previous</a><?php endif;?></li> <?php for($i=1;$i<=$current_page+5;$i++):?> <li class="<?php if($i==$_GET['p']) echo "active";?>"><?php if($i!=$_GET['p']):?><a href="reports.php?p=<?php echo $i;?>&<?php echo $clean_query_string;?>"><?php echo $i;?></a><?php else:?><a href="#"><?php echo $i;?></a><?php endif;?></li> <?php endfor;?> <li class=""><a href="#">...</a></li> <li class=""><a href="reports.php?p=<?php echo $pages;?>&<?php echo $clean_query_string;?>"><?php echo $pages;?></a></li> <li class="next <?php if($_GET['p']==$pages):?>disabled<?php endif;?>"><?php if($_GET['p']==$pages):?><a href="#">Next →</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']+1;?>&<?php echo $clean_query_string;?>">Next →</a><?php endif;?></li> <?php endif;?> <?php if($current_page > 5 && $current_page < $pages-5):?> <li class="prev <?php if($_GET['p']==1 || !isset($_GET['p'])):?>disabled<?php endif;?>"><?php if($_GET['p']==1 || !isset($_GET['p'])):?><a href="#">← Previous</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']-1;?>&<?php echo $clean_query_string;?>">← Previous</a><?php endif;?></li> <?php if($current_page>=7):?> <li class=""><a href="reports.php?p=1&<?php echo $clean_query_string;?>">1</a></li> <li class=""><a href="#">...</a></li> <?php endif;?> <?php for($i=$current_page-5;$i<=$current_page+5;$i++):?> <li class="<?php if($i==$_GET['p']) echo "active";?>"><?php if($i!=$_GET['p']):?><a href="reports.php?p=<?php echo $i;?>&<?php echo $clean_query_string;?>"><?php echo $i;?></a><?php else:?><a href="#"><?php echo $i;?></a><?php endif;?></li> <?php endfor;?> <?php if($current_page<=$pages-6):?> <li class=""><a href="#">...</a></li> <li class=""><a href="reports.php?p=<?php echo $pages;?>&<?php echo $clean_query_string;?>"><?php echo $pages;?></a></li> <?php endif;?> <li class="next <?php if($_GET['p']==$pages):?>disabled<?php endif;?>"><?php if($_GET['p']==$pages):?><a href="#">Next →</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']+1;?>&<?php echo $clean_query_string;?>">Next →</a><?php endif;?></li> <?php endif;?> <?php if($current_page >= $pages-5):?> <li class="prev <?php if($_GET['p']==1 || !isset($_GET['p'])):?>disabled<?php endif;?>"><?php if($_GET['p']==1 || !isset($_GET['p'])):?><a href="#">← Previous</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']-1;?>&<?php echo $clean_query_string;?>">← Previous</a><?php endif;?></li> <li class=""><a href="reports.php?p=1&<?php echo $clean_query_string;?>">1</a></li> <li class=""><a href="#">...</a></li> <?php for($i=$current_page-5;$i<=$pages;$i++):?> <li class="<?php if($i==$_GET['p']) echo "active";?>"><?php if($i!=$_GET['p']):?><a href="reports.php?p=<?php echo $i;?>&<?php echo $clean_query_string;?>"><?php echo $i;?></a><?php else:?><a href="#"><?php echo $i;?></a><?php endif;?></li> <?php endfor;?> <li class="next <?php if($_GET['p']==$pages):?>disabled<?php endif;?>"><?php if($_GET['p']==$pages):?><a href="#">Next →</a><?php else:?><a href="reports.php?p=<?php echo $_GET['p']+1;?>&<?php echo $clean_query_string;?>">Next →</a><?php endif;?></li> <?php endif;?> <?php endif;?> </ul> </div> <?php endif;?>