Web Analytics Made Easy -
StatCounter Ahh Too Many Pages. - CodingForum

Announcement

Collapse
No announcement yet.

Ahh Too Many Pages.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ahh Too Many Pages.

    I have a script running that sets page numbers and so far it has worked quite well for me. No real complaints.

    The Script is as foallows:

    PHP Code:
    // If current page number, use it
    // if not, set one!

    if(!isset($_GET['page'])){
        
    $page 1;
    } else {
        
    $page $_GET['page'];
    }

    // Define the number of results per page
    $max_results 10;

    // Figure out the limit for the query based
    // on the current page number.
    $from = (($page $max_results) - $max_results);

    // Figure out the total number of results in DB:
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM $table"),0);

    // Figure out the total number of pages. Always round up using ceil()
    $total_pages ceil($total_results $max_results);


    // Build Previous Link
    if($page 1){
        
    $prev = ($page 1);
        echo 
    "<a href=\""
        
    .$_PHP_SELF
        
    ."?page=$prev\">"
        
    ."<< Previous</a> ";
    }

    for(
    $i 1$i <= $total_pages$i++){ // Builds page numbers
        
    if(($page) == $i){
            echo 
    "$i | ";
            } else {
               echo 
    "<a href=\""
                       
    .$_PHP_SELF
                    
    ."?page=$i\">$i</a>&nbsp;|&nbsp;";
        }
    }

    // Build Next Link
    if($page $total_pages){
        
    $next = ($page 1);
        echo 
    "<a href=\""
        
    .$_PHP_SELF
        
    ."?page=$next\">Next >></a>";

    Now the problem is I was using the script to page out an adminstration page for some items but it's 70+ pages! yikes!:uhoh:

    Of course it doesn't wrap around and extends the page waaay farther than I would like it to. And even if it did wrap around cosmetically it doesn't look neat. I would like a page nunmbering schemes that go something like

    1 2 3 >> .... last page.
    how can I achieve this amazing feat? Thanks in advance.
    Last edited by MAbans; Feb 27, 2004, 06:57 PM.

  • #2
    What doesn't wrap around what? What is it that you are wanting to do?
    Spookster
    CodingForum Supreme Overlord
    All Hail Spookster

    Comment


    • #3
      Of course it doesn't wrap around and extends the page waaay farther than I would like it to. And even if it did wrap around cosmetically it doesn't look neat. I would like a page numbering schemes that go something like

      1 2 3 >> .... last page.
      how can I achieve this amazing feat? Thanks in advance.

      Comment


      • #4
        I read that the first time. You never specified what "it" is?

        What wraps around what? Your description is not obviously clear.
        Spookster
        CodingForum Supreme Overlord
        All Hail Spookster

        Comment


        • #5
          Well theorically it displays the actual page numbers within a table it should wrap and go to the next line beneath it correct? Well it does not.

          Like this: http://69.13.156.225/pages.php

          Now in this case there are 210 page with the results being 10 at 1 time. Now if this was the case, of it still wrapping around the table and previously indicated, it STILL wouldn't look all that great. Which leads into the meat of my question which I may add has nothing to do with wrapping.

          How can I achieve a page number system that stops at let's say at page 10 within that number system.

          Example
          1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 >>

          But has a continuation button that off sets the numberical order by let's say 5 or another 10?

          So you would be able to see this upon click the ">>" link

          11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 >>

          and so on.


          Hence why I included the example

          1 2 3 >> .... last page
          Clear now?

          Comment

          Working...
          X