About The Multisearch.php

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

By Tom - April 3, 2017

Hello,

A question about the multisearch.php

Currently the search field is something like this

'searchFields'    =>  array('ref_no','title_text','studio'),

The question is about the ref_no.

The reference number we stored in the db is something like this

abc123, sss345

The multisearch runs perfect if the user search abc123, abc, abc1

however, if the user search abc-123,

there is no result found.

Please advice is it possible if the user search abc-123,

then the result of abc123 will be shown.

Thanks a lot.

By Tom - April 12, 2017

Thanks a lot Damon

By Tom - May 15, 2017 - edited: May 15, 2017

Hello,

Sorry for trouble again.

I have created a field named ref_no1

And I intend to update the ref_no1 from ref_no

For example

In ref_no

ABC123

Then in ref_no1

ABC-123

I know how to do it in php

<?php
echo preg_replace('/^([A-Za-z]+)([0-9]+)$/i', '$1-$2', $listingsRecord['ref_no']);
?>

However I really don't know how to do it in mysql console to update the ref_no1 column.

Please advice.

Thanks a lot

By Dave - May 18, 2017

Hey Tom, 

As an alternate approach, if dashes aren't needed and you're always searching for ref_no values what about just removing dashes from the keyword the user searches for?  So if they search for ABC-123 or ABC123 or -ABC123- it all searches for ABC123?

$searchOptions['keywords'] = str_replace('-', '', @$_REQUEST['q']); // remove dashes

Hope that helps.

Dave Edis - Senior Developer
interactivetools.com

By Tom - May 18, 2017

Thanks a lot for your great help Dave.