Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Usage: doPagination($totalrows,$p,$numofp);
- $totalrows = The total number of rows returned by the query
- $p = The current page, default would be 1
- $numofp = The total number of pages (this will depend on the total rows and limit)
- function doPagination($totalrows,$p=1,$numofp)
- { ?>
- <div class="pagination"><ul><li><a href="?" title="reload"><?=$totalrows?> Record<?php if($totalrows>1) {?>s<?php } ?></a></li>
- <?php if($p>2) { ?> <li><a href="<?=PHPSELF?>?" title="first">« «</a></li> <?php } ?>
- <?php if($p>1) { ?> <li><a href="<?=PHPSELF?>?p=<?=$p-1?>" title="previous">«</a></li> <?php } ?>
- <?php for($i = $p; $i <= $p+LIMIT; $i++) { if($i == $p) { ?> <li class="active"><a href="#"><?=$i?></a></li> <?php } else { if($i<$numofp) { ?> <li><a href="<?=PHPSELF?>?p=<?=$i?>"><?=$i?></a></li> <?php } } } ?>
- <?php if($p<$numofp) { ?> <li><a href="<?=PHPSELF?>?p=<?=$p+1?>" title="next">»</a></li> <?php } ?>
- <?php if($p<$numofp) { ?> <li><a href="<?=PHPSELF?>?p=<?=$numofp?>" title="last">» »</a></li> <?php } ?>
- </ul></div>
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement