Search form - search multiple fields for keywords

5 posts by 3 authors in: Forums > CMS Builder
Last Post: October 7, 2008   (RSS)

Hi,

I'm working on a search form which is to search keywords from a number of fields, using one <input> field (i.e. the one input searches the keyword through a number of fields and displays results based on OR criteria.)

Starting with a direct link to results:

page.php?field1_keyword,fieldb_keyword=test

This displays results based on AND - i.e. 'test' is found in both field1 and field2, rather than the AND/OR (i.e. 'test' is in either field1 and field2 (or indeed both)). It's the AND/OR criteria that I'm after)

And I need to get this into a form version (rather than a direct link)

So, I have:
<input type="text" name="field1_keyword,field2_keyword" />

Using the above <input> the results page is as follows:
page.php?field1_keyword%2Cfield2_keyword=text
And this doesn't work either (displays no results)

If I place a space in between the fields in name="":

<input type="text" name="field1_keyword, field2_keyword" />

I get the following results URL and it displays all results (i.e. ignoring keyword criteria.

Is there anyway I can get the one <input> field to do what I want?

Cheers in advance,
Rob

Re: [rjbathgate] Search form - search multiple fields for keywords

By Donna - October 6, 2008

Hi Rob,

At the moment, "OR" searches are not possible in CMS Builder without some custom programming. If you'd like to get a quote on that, drop us an email and we can discuss it further. :)
Donna

--
support@interactivetools.com

Re: [Donna] Search form - search multiple fields for keywords

Hi Donna,

Cheers for the reply.

I might be able to work around the AND problem - but how do I have the <input> search both fields for the keyword?

The two <input> lines written above don't seem to work in creating the end result of looking in both fields, as the below url would:

page.php?field1_keyword,fieldb_keyword=test

Thanks again
Rob

Re: [rjbathgate] Search form - search multiple fields for keywords

By Dave - October 7, 2008

Hi Rob,

Try this: page.php?field1,fieldb_keyword=test

And see the docs here for more info on different search query formats:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

And as for "OR" and advanced searching - it get's pretty complicated pretty quick and we end up re-creating SQL. The simplest way to do it is to give your field a custom name, manually generate the WHERE and pass that as an option to getRecords().

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com