Log in

View Full Version : PHP Paging With Custom Pagesize



cancer10
11-05-2008, 05:58 PM
Hello,

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

And noticed this line:

$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

Jesdisciple
11-06-2008, 02:20 AM
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

cancer10
11-06-2008, 03:26 PM
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

Jesdisciple
11-06-2008, 07:25 PM
I think #2 & 3 should be expected. But either way, could you post the entire PHP you're using?

cancer10
11-07-2008, 03:42 AM
Will do it when I reach home.

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

Any logic behind it?


Thanx

Jesdisciple
11-07-2008, 03:52 AM
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.

cancer10
11-07-2008, 03:53 AM
Yes, it displays X rows per page.

Jesdisciple
11-07-2008, 03:54 AM
And that's what's happening here, so you're fulfilling your contract with the user.
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)