I'm dealing with a situation where I can potentially have over 3000
results to display from a database. I'm successfully paginating the
results, 10 at a time, but don't want to display 300+ page links at the
bottom.

How can I group the pages to show, for example, the first 10 pages,
followed by a "next 10" link?

i.e., Page: 1 2 3 4 5 6 7 8 9 10 > >> Next 10

My current code:
// $display_num = 10 -- the number of results we're showing at a time
// $start = 0 -- assuming we're starting on the first page of results

if ($num_pages > 1) {
  if ($start == 0) {
    $current_page = 1;
  } else {
    $current_page = ($start/$display_num) + 1;
  }
  if ($start != 0) {
    echo '<a href="mypage.php?start=' . ($start-$display_num) .
'">Prev</a> ';
  }
  // don't show the current page as a link
  for ($i = 1; $i <= $num_pages; $i++) {
    $next_start = $start + $display_num;
    if ($i != $current_page) {
      echo '<a href="mypage.php?start=' . (($display_num * ($i - 1))) .
'">' . $i . '</a> ';
    } else {
      echo $i . ' ';
    }
  }
  if ($current_page  != $num_pages) {
    echo '<a href="mypage.php?start=' . ($start+$display_num) .
'">Next</a> ';
  }
}



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/HKFolB/TM
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to