Jump to content

adding get variables to url?


fael097

Recommended Posts

hi, i have a question, that i didnt manage to figure out myself.

you know when you have a search engine, and you want to apply filters, and sort stuff by given parameter?

if you simply make this:

<a href="?filter1=low">low prices</a>
<a href="?filter2=best">best rated</a>

it wont keep both filters, if you click the first one, and then click the second one, it will replace the first clicked.

my workaround for this so far:

<a href="?filter1=low&filter2=<?php echo $_GET['filter2']; ?>">low prices</a>
<a href="?filter2=best&filter1=<?php echo $_GET['filter1']; ?>">best rated</a>

but thats not good when you have like 10 filters (wich is my case) you'll have an extense code for each anchor href...

so i was trying to figure out a way to simply add variables to a $url variable, like if $_GET[variable] is set, $url.="add variable", and if that variable is already set, replace if its different, or keep if its equal, but i dont know if thats possible cuz i didnt manage to make it.

is it doable?

thanks in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.