How can I add GET variables to the end of the current page url using a form with php? -


I have some database information that is being displayed on a page.

I am using a pagegine class which uses the $ _GET ['page'] variable in the URL. When you click the anchor tag on a different page, it changes the $ _ GET ['page'] to a new number in the URL and displays related results.

I have sort and search features that get $ _ GET ['searchby'] and $ _ ['search_input'] of variable Uses the user to enter their search criteria on the form that is using GET. The variable is then put in the URL which allows to show the correct result.

Whatever problem I have, whenever I click on paging link, it adds $ _ GET ['page'] at the end of the URL and erases the variable $ _ GET ['searchby'] or $ _ GET ['search_input'] . When I submit the search form, it adds $ _ GET ['searchby'] and $ _ [find_input '] but $ _ GET wins ['page'] .

How to add GET variables at the end of the current page URL using anchor tag and search / sort form, to erase any existing GET variables, but if they are the same GET variable name?

Try it out:

  if (strpos ($ _ server) REQUEST_URI '],'? ')! == incorrect) {$ url = $ _SERVER ['REQUEST_URI'] '& Amp; Var = value '; } And {$ url = $ _SERVER ['REQUEST_URI'] '? Var = value '; } & Lt; A href = "& lt; php echo $ url; & gt; & Gt; Go & lt; / A & gt;  

Note that $ _ SERVER ['REQUEST_URI'] gives you the current URL, including the query string value.


Comments