Pagination Problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
royalblue
Forum Newbie
Posts: 13
Joined: Sun May 16, 2004 8:26 am

Pagination Problem

Post by royalblue »

I am using Dreamweaver mx 2004, php and MYSQL:

When I insert recordet Navigation bar in dreamweaver the 'Next' and 'Previous' Text do not seem to work with my recordset.
The following PHP Code exists for the 'Previous' Text (for recordset 'Test2')

<?php if ($pageNum_Test2 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Test2=%d%s", $currentPage, max(0, $pageNum_Test2 - 1), $queryString_Test2); ?>">Previous</a>
<?php } // Show if not first page ?>

The following code exists for the 'Next' Text for the same recordset:

<?php if ($pageNum_Test2 < $totalPages_Test2) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Test2=%d%s", $currentPage, min($totalPages_Test2, $pageNum_Test2 + 1), $queryString_Test2); ?>">Next</a>
<?php } // Show if not last page ?>

This occurs on a master page that has been fed from a submit form (method Post). The odd thing is is that this code works for a recordset on another page that is fed from a URL Parameter!

Does anybody know what is wrong with the code?
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Do you have more than one page in the record set?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Pagination is very tricky I think. I had the exact same problem but I managed to get it to work. Have a look at my topic:

viewtopic.php?t=22008&highlight=
royalblue
Forum Newbie
Posts: 13
Joined: Sun May 16, 2004 8:26 am

Post by royalblue »

I definitely have more than one page in the recordset.
I have reviewed the tutorial on your link before and it seems rather wieldy for my purposes. I've done all the MYSQL Stuff in my Dreamweaver table and just want to insert a small piece of code underneath it to paginate. This is indeed a frustrating problem !
It seems odd that the code works when the page is 'fed' from a URL Parameter but does not work when fed from a submit form??

Comments please......
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

royalblue wrote:It seems odd that the code works when the page is 'fed' from a URL Parameter but does not work when fed from a submit form??

Comments please......
If your script assigns variables (current page/record as example) from the URI using the superglobal $_GET, a submit form will not help. A form uses $_POST so that might be the issue.

Try to look up further in the script to see what happens, and add some echo $var; on various of places to see what happens within the script.

If everything else fails, post some code on how the variables are assigned their values from the URI. (And use PHP tags.) Good luck.

Edit:
I'm above blatantly assuming that you ARE indeed using $_GET/$_POST with register_globals off and so on as the majority of users.
Post Reply