0

I have a webpage which allows users to filter results. Once a filter is set it is appended to the URL eg: www.testsite.com?show=active. The results are broken into several pages (simple pagination) once a user clicks a certain page the page is also appended to the user like www.testsite.com?page=3. The problem I have is that after applying a filter and then clicking a page number the URL should be www.testsite.com?show=active&page=3 but instead the URL turn into just www.testsite.com?page=3 loosing the previously set filter.

I set the href to the pagination links as follows <a href='?page=3'>3</a> and to the filter links as <a href="?show=active">Active items</a>

Any help to resolve this issue is appreciated.

2 Answers 2

1

$_SERVER['QUERY_STRING'] WILL PRESERVE IF.. YOU CAN APPEND IT AFTER page varaible

Sign up to request clarification or add additional context in comments.

Comments

1

You can use

 $_SERVER['QUERY_STRING']

To get the current query string

You can prepend it to your links like

 '?' . <?= $_SERVER['QUERY_STRING']; ?> . '&show=active'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.