Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: next page link

  1. #1
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts

    next page link

    I have pages, 1.php, 2.php, 3.php and so on. I would like to make a next page and last page links at the bottom of each of them. Is there a way to get the pagename then take the .php off of it, and then add or subtract 1 and then echo that?
    PHP Code:
    $nextpage "(php_self - .php + 1)";
    $lastpage "(php_self - .php - 1)"
    I know that is not even close, but use that idea.


    Thanks,
    ILLINI
    Why not thank me?

    http://adamsworld.name

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    PHP Code:
    $thisnum = (int) pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME); // to use th cast method, the number must be the FIRST thing in the filename
    $prev = ($thisnum 1) ? $thisnum false// don't go below one
    $next = (file_exists($thisnum '.php')) ? $thisnum false// check if the next higher number exists... alternatively, you can just check against a static max here

    if ($prev)
    {
        echo 
    '<a href="' $prev '.php">Previous</a>';
    }
    if (
    $next)
    {
        echo 
    '<a href="' $next '.php">Next</a>';


  • #3
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    THank you, That worked.
    But I have a problem. I changed my page structure. Now I have ?type=html?p={number here now}
    Could you please try to do the same thing only with my new links?
    Thanks,
    ILLINI
    Why not thank me?

    http://adamsworld.name


  •  

    Posting Permissions

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