0

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 .

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
didyeg
  • 35
  • 5

1 Answers1

1

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

Community
  • 1
  • 1
elzi
  • 5,442
  • 7
  • 37
  • 61
  • I don't know what values those variables have, what the implementation is, or an explanation of how it is not working. I can't read your mind. It looks like you're generating a string from a couple different variables, under the condition `$page`, which I assume is an integer, is greater than 1. Where are you rendering it? So little information. Here's an article on PHP debugging I think you could benefit from: http://blog.teamtreehouse.com/how-to-debug-in-php – elzi Sep 17 '14 at 20:19