Results 1 to 8 of 8

Thread: PHP Paging With Custom Pagesize

  1. #1
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Question PHP Paging With Custom Pagesize

    Hello,

    I was going through this tutorial:
    http://www.php-mysql-tutorial.com/php-mysql-paging.php

    And noticed this line:
    Code:
    $rowsPerPage = 20;
    Here, we are defining the Rows per page in the code itself. I was wondering, if I allow my visitors to set this value from the webpage itself, what bugs would that carry in my code (assuming I am using the exact code in the link above)?

    Thanx

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Just a sec... Hmm, no cosmic vibrations pertain to your situation, so I have no idea what bugs might occur in such an implementation. (It's nothing personal; I just had a sarcastic moment.) But here's what you need to read if you want to build it: http://www.php.net/manual/en/intro.session.php
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. The Following User Says Thank You to Jesdisciple For This Useful Post:

    cancer10 (11-06-2008)

  4. #3
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    The reason why I asked u this question was, I currently have 8 records in my DB. The navigation/Pagination works fine if my customer enters any value in the PageSize textbox except the value 1, 6 and 7.

    1) If they enter the value 1 in the PageSize textbox then the nav pagination loops from 0 to 7. Clicking on the [7th] hyperlink, gives a record not found error.

    2) If they enter the value 6, then the page displays only 6 rows. (Not sure why)

    3) If they enter the value 7, then the the page displays only 7 rows. (Not sure why)

    For the remaining values, it displays all the 8 records. Which is fine.

    Any idea why is this happening?

    Thanx

  5. #4
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    I think #2 & 3 should be expected. But either way, could you post the entire PHP you're using?
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  6. #5
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Will do it when I reach home.

    BTW, can u plz explain whu #2 and 3 should be expected?

    Any logic behind it?


    Thanx

  7. #6
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    I interpret "allow[ing] [your] visitors to set [the number of rows] from the webpage itself" to mean that if the user enters a value X, then the page displays X rows.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  8. #7
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Yes, it displays X rows per page.

  9. #8
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    And that's what's happening here, so you're fulfilling your contract with the user.
    Quote Originally Posted by cancer10 View Post
    2) If they enter the value 6, then the page displays only 6 rows. (Not sure why)

    3) If they enter the value 7, then the the page displays only 7 rows. (Not sure why)
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •