Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- http://stackoverflow.com/questions/11917775/shorten-condense-number-of-pages-in-pagination -->
- <form action="" method="get">
- <input name="page" type="text" value="" />
- <input name="send" type="submit" value="send">
- </form><br/>
- <div id="user_nav_bottom">
- <?php
- $pages = array(30); for ($i=1;$i<=30;$i++) $pages[$i-1]='<p>page'.$i.'</p>';
- $current = $_GET['page'];
- $last = count($pages)+1;
- $curr0 = $current-2;
- $curr1 = $current+2;
- if ($curr0<=1) {
- $curr0 = 1;
- $curr1 = $last>5? 5 : $last;
- }
- if ($curr1>=$last) {
- $curr0 = $last-4 < 1 ? 1 : $last-4;
- $curr1 = $last;
- }
- // now print all links:
- echo '<a href="imgit_images.php?page=1">«</a> ';
- for ($i=$curr0; $i<=$curr1; $i++) {
- $style = ($i==$current)? 'font-weight:bold':'';
- echo ' <a href="imgit_images.php?page='.$i.'" style="'.$style.'">'.$i.'</a> ';
- }
- echo '<a href="imgit_images.php?page='.$last.'">»</a> ';
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement