Skip to main content
boloco
Known Participant
November 10, 2009
Answered

PHP Recordset Paging - Recordset Navigator Bar

  • November 10, 2009
  • 1 reply
  • 1303 views

Hi There!

Look at this page:

http://martinique.org/martiniquenew/discovery/towns-villages.php

Use the Navigator bar to page through and you'll notice a very annoying thing - the page jumps to the top.

How can we prevent that to happen so we stay at the same level of the page when we navigate through the database?

Thank you much for your answers.

This topic has been closed for replies.
Correct answer David_Powers

Using the recordset navigation bar reloads the page, so it naturally goes to the top. To get the page to reload at a particular place within the page, you need to add an ID to the element you want to navigate to, and add it at the end of the URL preceded by a hash sign.

The following example shows the ID mainDiv added to the end of the Next code from a recordset navigation bar:

<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>#mainDiv">Next</a>

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
November 10, 2009

Using the recordset navigation bar reloads the page, so it naturally goes to the top. To get the page to reload at a particular place within the page, you need to add an ID to the element you want to navigate to, and add it at the end of the URL preceded by a hash sign.

The following example shows the ID mainDiv added to the end of the Next code from a recordset navigation bar:

<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>#mainDiv">Next</a>

boloco
bolocoAuthor
Known Participant
November 10, 2009

Thank you very much David!

As usual you're right on target. (I made up this expression, I hope it make sense);-)

Just so you know, your books are THE Bible of web design/development for me.

I'm fortunate I met you through the books you wrote and I made so much progress since I got them.

I'm sure you have students coming from everywhere in the world.

Well, I'm one of your Senegalese student.

Thank you very much again!

David_Powers
Inspiring
November 10, 2009

Glad to have been of help. Thanks for your kind words about my books.