Page 1 of 1

Nother Pagination Q

Posted: Tue Sep 07, 2004 11:10 pm
by Steveo31
viewtopic.php?t=25692&highlight=

There's the battle that was finally won. The question I have now is about showing the page numbers. Some of the results will have 40 pages, and I'd like it to show the pages like the forums here,

Code: Select all

First 1, 2, 3... Last
I can't figure it out. I've thought about loops, but can't figure how to implement.

Posted: Tue Sep 07, 2004 11:18 pm
by feyd
psuedo code:

Code: Select all

if num_pages < 6
  loop out page links to all pages
else
  loop out page 1, 2, 3
  drop an ellipsis
  loop out current_page - 1 -> current_page + 1
  drop an ellipsis
  loop out page n - 2, n - 1, n (last_page)
  remove overlaps, favoring the previously set.

Posted: Tue Nov 02, 2004 9:29 pm
by Steveo31
Ok, I've been at this for a while... no luck.. Here's the code I thought might work, but nope.

Code: Select all

$limit = $totalPages-($totalPages-$page);
                        if($limit > 10){
                            $limit = 10;
                        }else{
                            $limit = $totalPages-($totalPages-$page);
                        }
                        for($p=$page; $p<$limit; $p++){
                            if($p != $page){
                                echo "<a href='$url&page=$p'>".$p."</a>&nbsp;";
                            }else{
                                echo "<b style='color:#999'>".$p."</b>&nbsp;";
                            }
                        }
I can't put my train of thought into words... made sense about 10 min ago, but I can't think now... overkill. Hah.

If you could, give me another push :)