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 4 of 4

Thread: php help

  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php help

    Hello,
    I have been working on a website, loading images from database with php. There are previous and next links for additional pages, with a limit of 5 images per page. If there is (for example) 17 images the next link is disabled when the last page is reached. However, if the last page is a multiple of 5, the next link does not get disabled as it should. Here is the link for an example.
    http://www.alhebert.us/painting.php
    If you notice, the painting page has 25 images, so the next link does not work right on the last page.
    If you returned home, then went to art metalwork, there are 6 images, and it disables as it should.

    PHP Code:

    if ($nr 5)
    {
    echo 
    " | <font color='CCCCCC'>Next</font><br><br>";
    }
    else
    {
    echo 
    " | <a href='painting.php?cps=$cps&lps=$lps'>Next</a><br><br>";
    }

    print 
    "Images $a - $b of $nr0<br><br>";
    //print "$a";
    //print "$b"; 

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    The way you're doing it is all wrong. You should use the variable that works out the Images 21 - 25 of 25 and check if the upper value of the images being displayed is the same as the total. If it is, don't show the next link (disabled)
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    This worked

    Hi
    Thank you so much, This works.

    PHP Code:
    if ($b >= $nr0)
    {
    echo 
    " | <font color='CCCCCC'>Next</font><br><br>";
    }
    else
    {
    echo 
    " | <a href='painting.php?cps=$cps&lps=$lps'>Next</a><br><br>";
    }

    print 
    "Images $a - $b of $nr0<br><br>"

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    No problem
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

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