Jump to content

Multiple Search in template


mrkhan
 Share

Recommended Posts

Hello,
i am trying to search page with multiple options like, 
i have one select box where i can select multiple items as
 

<select id="tokenize" name="tokenize" multiple="multiple" class="tokenize-sample" />

i have GET form and when i submit the form i get values like

search/?tokenize=abc&tokenize=xyz

now in my search page

$children = $pages->find("template=property, Ad_Type=".$ptype." ,Area=".$tokenize);



as you can see i have passed multiple values of tokenize, how can i search page contains all values ?

 

Thanks

 

  • Like 1
Link to comment
Share on other sites

Hi, maybe you could pass your variables as Array. 

You should name your select

<select name="tokenize[]" >


Then when you receive it, create an "OR" type of condition for the selector, using a foreach to iterates over it, or maybe a function.

$customOrSelector = implode("|", $_GET['tokenize']);

And finally, apply it to your query:

$children = $pages->find("template=property, Ad_Type=".$ptype." ,Area=".$customOrSelector);

 

Hope this help.

 

NOTE: Don't use this example in a production environment, is not safe to use variables directly from $_GET or any other user input without sanitize them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...