Multi Field Search

5 posts by 4 authors in: Forums > CMS Builder
Last Post: November 5, 2013   (RSS)

Is there a simple way to search multiple fields at once? Here is an example search form:

<form id="search" name="search" method="get" action="/search.php">
<input name="title_keyword" type="text"  />
<input type="submit" name="submit" value="Submit">
</form>

So for name, could we list multiple fields like this?

name="title_keyword,content_keyword,etc..."

Thanks

By zip222 - November 5, 2013

Multisearch is likely overkill for your needs...

You just need to modify the form code you have slightly...

<form id="search" name="search" method="get" action="/search.php">
<input name="title,other,and_another,content_keyword" type="text"  />
<input type="submit" name="submit" value="Submit">
</form>

you can include as many fields as you want, and just you need to add "_keyword" to the final field in the list.

Special fields like dates and drop downs lists won't necessarily be searched the way you might expect.

By ross - November 5, 2013

Hi theclicklab

I think zip222 has you on the right track. I think starting with modifying keyword field on your form and that should get things going. If it doesn't give you the desired results, we can take it to the next step from there.

Let us know how you make out :).

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

I had tried the "title,other,and_another,content_keyword" method before but it did not work, probably because I had appended "_keyword" on every field rather than just the last one as mentioned by zip222

So thanks for all the feedback everyone - will give it a go.