didyeg
didyeg

Reputation: 35

Change URL using PHP without removing the existing variables

How can i change the URL using PHP, I asked this question before but i didn't receive any answer . so this is my problem i want to add a pagination to my index page ,but in index page i have some icons that's filter some products , so the URL can be like that

www.mywebsite.com?id=66

so the problem is when i click on next (pagination) the URL instead of this

www.mywebsite.com?id=66&page=2

i get this

www.mywebsite.com?page=2

so my question is how can i add that parm the URL without removing the existing one using PHP because i tried with JavaScript but i didn't success .

Upvotes: 0

Views: 145

Answers (1)

elzi
elzi

Reputation: 5672

I think you want to use http_build_query

Example:

http_build_query(array_merge($_GET, array('newVariable'=>'someValue')))

Also - possible duplicate of Manipulate a url string by adding GET parameters

Upvotes: 1

Related Questions