Skip to main content
boloco
Known Participant
December 7, 2009
Answered

Paging control and URL parameters

  • December 7, 2009
  • 1 reply
  • 558 views

Hi there,

Please check out this page:

http://martinique.org/activities/sports.php

Go to the section "Skiing Surfing"

1 - Use the navigation to go through the records.

2 - Take a look at the URL in the browser window.

Now, please go to the section "Hiking" and repeat 1 & 2.

Note that the URL is appending the new parameters instead of replacing the previous one.

What am I doing wrong here.

Please help me to solve this problem.

Thank you much!

This topic has been closed for replies.
Correct answer David_Powers

The code generated by the Dreamweaver recordset navigation bar automatically adds any existing variables to the end of the query string. The following code (just above the DOCTYPE) comes from a recordset navigation bar on one of my pages:

$queryString_listAuthors = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_listAuthors") == false &&
        stristr($param, "totalRows_listAuthors") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);

I haven't tested this, but to eliminate the extra variables in the query string, comment out the whole of the if statement like this:

$queryString_listAuthors = "";
/*
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_listAuthors") == false &&
        stristr($param, "totalRows_listAuthors") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
  }
}
*/
$queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);

You will need to do that for each of your recordset navigation bars.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
December 7, 2009

The code generated by the Dreamweaver recordset navigation bar automatically adds any existing variables to the end of the query string. The following code (just above the DOCTYPE) comes from a recordset navigation bar on one of my pages:

$queryString_listAuthors = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_listAuthors") == false &&
        stristr($param, "totalRows_listAuthors") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);

I haven't tested this, but to eliminate the extra variables in the query string, comment out the whole of the if statement like this:

$queryString_listAuthors = "";
/*
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_listAuthors") == false &&
        stristr($param, "totalRows_listAuthors") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_listAuthors = "&" . htmlentities(implode("&", $newParams));
  }
}
*/
$queryString_listAuthors = sprintf("&totalRows_listAuthors=%d%s", $totalRows_listAuthors, $queryString_listAuthors);

You will need to do that for each of your recordset navigation bars.

boloco
bolocoAuthor
Known Participant
December 7, 2009

It works!

Thank you very much David!

David_Powers
Inspiring
December 8, 2009

Good. I was fairly confident that it would solve your problem, but didn't have the time to run any tests. Thanks for letting me know.