Copy link to clipboard
Copied
Hello,
I want to add multiple URL parameters to link.
what i have now is this:
../results.php?type=1&type=2
but the parameter should pass this:
type=1 OR type=2
Thanks
Copy link to clipboard
Copied
It's not clear to me what your problem is. A field in a querystring can be associated with more than one value, as you are doing in your first example. It's up to your script to then parse it and determine what to do with it. Can you explain in a little more detail what you are trying to do?
Copy link to clipboard
Copied
Hi, thanks for responding.
What i want the parameter to pass is EITHER [ type=1 OR type=2 ] but as in my first example i only know how to add a parameter that passes both types with "&"
Copy link to clipboard
Copied
Although URL parameter passing looks positional, php actually parses the string that is passed so that
page2.php?Type1="foo"
and
page2.php?Type2="bar"
both work provided you parse the string as $_GET['Type1']." and ".$_GET['Type2']
If you don't know what type the strings are when you create the URL string so that you can not label them correctly, then your only recourse would be to parse the string to decide what it contains.
Can you give a more concrete example of what you are trying to accomplish?
Copy link to clipboard
Copied
Querystrings include lists of parameters separated by the ampersand. There is no concept of 'OR', nor is one required. It's up to your script to process the values in any way that's appropriate. If you are using these values in a SQL query, then your query would include OR logic. Or, if you want the possibility of processing as OR or as AND, then you can include an additional querysting parameter to store this logical value. Make sense?
Copy link to clipboard
Copied
Hi,
Explaining my question, let's say I have link called "Books", it should take you
to "result page" and shows all results:
where type="children_books" and type="Sci_Fi_books" and "novels"When I add this URL Parameter for the link:Copy link to clipboard
Copied
../results.php?type=1&type=2&type=3 (3 is "novels")
That is because you have given 3 different values for the 'type' variable. Naturally it will assume the last value.
In your case you should either pass just one variable or two or three variables with different names.
In case of the first option you can have type=1 for children, type=2 for Sci_Fi or type=3 for novels as follows
../results.php?type=2 /*Sci_Fi
In case of the latter you can sort it out by using decision making statements like you will have somthing like
../results.php?chilren=1&Sci_Fi=0&novel=0 /*for children
Gramps
Copy link to clipboard
Copied
>> ../results.php?type=1&type=2&type=3
Gramps, assigning more than one value to a field in a querystring is perfectly valid. However, I know nothing about PHP so I'm not sure what the method would be to extract all of them. I imagine there's a way to iterate through the field list and extract the values.
Copy link to clipboard
Copied
Well I guess php does not handle this the same as other scripting languages I've used:
Go to
http://www.php.net/manual/en/function.parse-str.php
and read about how to handle duplicate field names.
Copy link to clipboard
Copied
I think you are missing a step between the URL parameters and the SQL query. You have to interpret the input (URL parameters) and create the appropriate query, where you can use "OR".
Barry
Find more inspiration, events, and resources on the new Adobe Community
Explore Now