Searching multiple fields with one text field

6 posts by 3 authors in: Forums > CMS Builder
Last Post: May 22, 2018   (RSS)

By gversion - May 21, 2018

Hello,

Is it possible to set up one text input field to carry out a "fieldname_prefix" search on two database fields?

e.g.

<input type="text" class="form-control" id="search" name="keywords_keyword,product_prefix" placeholder="Search">

The above code only carries out the search on "product" fieldname. I also want the search to be carried out on the "keywords" field.

I wonder if I can put the fields I want to search in an <input> hidden tag...?

Thanks as always for the help!

Regards,

Greg

By Codee - May 21, 2018

Hi Greg,

there are several modes of using the search form - and at least one of them can be used for searching multiple fields in records. One of the methods is a query through text fields, and it's important that the last field to be searched has "_query" addended to it.  I currently use one on a site (and it works well) that is similar to this

<span class="searchform">Type your search term in the box and click "Search Inventory". </span>
<form method="POST" action="/yourresultspage.php">
<input type="text" name="stock_number,year,additional_comments,license,make,model,title_query" value="">
<center>
<input type="submit" name="submit" value="Search Inventory">
</center>
</form>

By gversion - May 21, 2018

Hi equinox

Thanks for the reply - that's really helpful.

According to the below link, the 'query' search type will return, "Only records matching EVERY word or quoted phrase...":

https://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Is it possible to carry out different search types per field using one text input field? Or do they all need to use the same search type (e.g. "_query" from your example)? 

Thanks,

Greg

By Codee - May 22, 2018

Hi Greg,

What Leo said...

;-)

By gversion - May 22, 2018

Thanks, Leo!