Closed Thread
Results 1 to 12 of 12

Thread: [PHP] Pagelink

  1. #1
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310

    [PHP] Pagelink

    i started doing this this morning and have currently like 75 pages with another 4 that i have to add. so far i have 42 pages of it in a db. and i use the pagelinks. i wanna condense the number of links to maybe 10 with ... in between.

    like maybe Pages: 1 2 3 4 5 ... 38 39 40 41 42 or whatever corresponds to the last pages

    kinda like this

    http://neonsonline.com/pagelinks.jpg

    below is the actual page and the code i use

    http://www.neonsonline.com/gallery.php

    this is the code i use for the pagelinks

    PHP Code:

    echo "<center><table width=\"75%\" cellpadding=\"5\" cellspacing=\"0\" class=\"main\">
    <tr><td width=\"25%\" valign=\"top\">"
    ;
    if (
    $page != "1") {
    $prevpage $page 1;
    echo 
    "<a href=\"{$PHP_SELF}?page=$prevpage\">Prev. Page</a>";
    }
    echo 
    "</td><td width=\"50%\" valign=\"top\" align=\"center\">
    Pages:&nbsp;"
    ;
    $pagelink "1";
    do {
    if (
    $page == "$pagelink") {
    echo 
    "$pagelink&nbsp;";
    } else {
    echo 
    "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a>&nbsp;";
    }
    $pagelink $pagelink 1;
    } while (
    $pagelink <= $num_pages);
    echo 
    "</td><td width=\"25%\" valign=\"top\" align=\"right\">";
    if (
    $page != "$num_pages") {
    $nextpage $page 1;
    echo 
    "<a href=\"{$PHP_SELF}?page=$nextpage\">Next Page</a>";
    }
    echo 
    "</td></tr></table></center>"
    Last edited by ducktape; April 6th, 2003 at 14:03.
    I'm back after 2 years and 3 months.

  2. #2
    anti-liberal keith is an unknown quantity at this point keith's Avatar
    Join Date
    Oct 2000
    Location
    Buttsville
    Posts
    2,375
    check out this thread or search google for "php pagination"
    w3rd

  3. #3
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310
    thanks for the link none of it helped though im off to google

    i already have the pages listed i just wanna make the length a bit shorter there is currently 67 pages...lol

    http://www.neonsonline.com/gallery.php?page=3
    I'm back after 2 years and 3 months.

  4. #4
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    You code messy

    Mabe something like this?

    PHP Code:
    <?php

    // Config //////////////////////////////////////
    $pages_at_front 5;
    $pages_frontback_sep "...";
    $pages_at_back 5;
    ////////////////////////////////////////////////

    echo "<center><table width=\"75%\" cellpadding=\"5\" cellspacing=\"0\" class=\"main\"><tr><td width=\"25%\" valign=\"top\">";

    if (
    $page != "1") {
        
    $prevpage $page 1;
        echo 
    "<a href=\"{$PHP_SELF}?page=$prevpage\">Prev. Page</a>";
    }

    echo 
    "</td><td width=\"50%\" valign=\"top\" align=\"center\">Pages:&nbsp;";

    $pagelink 1;
    $printed_sep 0;
    do {

        if(
    $pagelink <= $pages_at_front) {
            if (
    $page == "$pagelink") {
                echo 
    "$pagelink&nbsp;";
            }
            
            else {
                echo 
    "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a>&nbsp;";
            }
        }

        elseif(
    $pagelink >= ($num_pages $pages_at_back)) {
            if(
    $printed_sep == 0) {
                echo 
    $pages_frontback_sep;
                
    $printed_sep == 1
            
    }

            if (
    $page == "$pagelink") {
                echo 
    "$pagelink&nbsp;";
            }
            
            else {
                echo 
    "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a>&nbsp;";
            }
        }

        
    $pagelink $pagelink 1;
    } while (
    $pagelink <= $num_pages);

    echo 
    "</td><td width=\"25%\" valign=\"top\" align=\"right\">";

    if (
    $page != "$num_pages") {
        
    $nextpage $page 1;
        echo 
    "<a href=\"{$PHP_SELF}?page=$nextpage\">Next Page</a>";
    }

    echo 
    "</td></tr></table></center>";

    ?>
    Last edited by Cagez; April 8th, 2003 at 06:54.

  5. #5
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310
    i just tried that it looks cool but gives me this

    http://www.neonsonline.com/gallery2.php
    I'm back after 2 years and 3 months.

  6. #6
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    Oop, the elseif is supposed to say $num_pages not num_page. Try it now.

  7. #7
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310
    alright i just changed the code and get

    PHP Code:
    Parse errorparse error in /home/virtual/site3/fst/var/www/html/gallery2.php on line 135 
    I'm back after 2 years and 3 months.

  8. #8
    FWS Addict dawizman is an unknown quantity at this point
    Join Date
    Apr 2002
    Location
    Alberta, Canada
    Posts
    607
    dunno, but try this, it seems to work on my server:

    PHP Code:
    <?php

    // Config //////////////////////////////////////
    $pages_at_front 5;
    $pages_frontback_sep "...";
    $pages_at_back 5;
    ////////////////////////////////////////////////

    echo "<center><table width='75%' cellpadding='5' cellspacing='0' class='main'><tr><td width='25%' valign='top'>";

    if (
    $page != "1") {
    $prevpage $page 1;
    echo 
    "<a href='{$PHP_SELF}?page=$prevpage'>Prev. Page</a>";
    }

    echo 
    "</td><td width='50%' valign='top' align='center'>Pages:&nbsp;";

    $pagelink 1;
    $printed_sep 0;
    do {

    if(
    $pagelink <= $pages_at_front) {
    if (
    $page $pagelink) {
    echo 
    $pagelink "&nbsp;";
    }

    else {
    echo 
    "<a href='{$PHP_SELF}?page=$pagelink'>" $pagelink "</a>&nbsp;";
    }
    }

    elseif(
    $pagelink >= ($num_pages $pages_at_back)) {
    if(
    $printed_sep 0) {
    echo 
    $pages_frontback_sep;
    $printed_sep 1;
    }

    elseif (
    $page == $pagelink) {
    echo 
    $pagelink "&nbsp;";
    }

    else {
    echo 
    "<a href='{$PHP_SELF}?page=$pagelink'>" $pagelink "</a>&nbsp;";
    }
    }

    $pagelink $pagelink 1;
    } while (
    $pagelink <= $num_pages);

    echo 
    "</td><td width='25%'valign='top' align='right'>";

    if (
    $page != $num_pages) {
        
    $nextpage $page 1;
        echo 
    "<a href='{$PHP_SELF}?page=$nextpage'>Next Page</a>";
    }

    echo 
    "</td></tr></table></center>";

    ?>
    Your man, DaWizman

  9. #9
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310
    alright works now i dunno what i did but it wasnt working at first.

    thanks for the help really appreciate it
    I'm back after 2 years and 3 months.

  10. #10
    FWS Addict dawizman is an unknown quantity at this point
    Join Date
    Apr 2002
    Location
    Alberta, Canada
    Posts
    607
    no problem
    Your man, DaWizman

  11. #11
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    Its pretty messy but if it does the job, then hey

  12. #12
    NLC ducktape is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Eden, NC
    Posts
    1,310
    i kinda gave up on this for a while but

    http://www.neonsonline.com/gallery2.php

    if you notice there are no ... but there are 6 numbers at the end and the first 5 numbers arent links but the last 6 numbers are

    and is there a way for it to show what page its on?maybe show up like this say if there were 70 pages and i was on 35

    1 2 3 ... 34 35 36 ... 68 69 70

    where the 35 would actually move where the person was at or
    maybe said something like page 35 of 70. and then show 1 page on each side of the actual page as in if i were on 17 the middle portion would read like 16 17 18

    or what would be even better is a drop down list. that lists like

    Page 1 (1-15)
    Page 2 (16-30)
    ....

    Thats what we had before i put it all in a database
    Last edited by ducktape; May 1st, 2003 at 01:08.
    I'm back after 2 years and 3 months.

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts