Search multiple fields

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 21, 2012   (RSS)

By benedict - March 16, 2012

Hi guys,

Using your search engine for the first time, but it does not seem to be working too well. I want the search to search across a product code, supplier code or description.

My search field is this:

<form method="POST" action="products_search.php" class="search-form">
<fieldset>
<div class="input-bg">
<input class="searcharea" name="supplier_barcode, code, description_keyword" type="text" value="Product Search"/>
</div>
<input class="search-btn" type="submit" value="" title="search" />
</fieldset>
</form>


And it just goes to products_search.php which is just a normal list viewer page.

Is there anything I'm missing? Am I able to search multiple fields in the one search form?

Re: [benedict] Search multiple fields

By benedict - March 20, 2012

Any word guys?

Re: [benedict] Search multiple fields

By (Deleted User) - March 20, 2012

Hi benedict,

When the form submits it sends all the post data to products_search.php which then uses that data to limit the records it loads for display.

At the top of products_search.php you should have something like:

if ( @$_REQUEST['supplier_barcode, code, description_keyword'] != '' ) {
// load records
list($records, $recordsMetaData) = getRecords(array(
'tableName' => {the table},
'perPage' => {the number of results per page, if desired},
));
}


I've added the if statement in case you want to display a message about not having entered any search criteria.

You can then manipulate the returned results as you need to.

Hope this helps,

Tom

Re: [benedict] Search multiple fields

By (Deleted User) - March 21, 2012

Hi benedict,

I needed more coffee yesterday it seems!

Good catch.

Tom