close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Search Results to narrow down to complete keyword

Thread began 8/26/2020 8:53 am by lr_leal239405 | Last modified 9/16/2020 8:24 am by Ray Borduin | 26 views | 7 replies |

lr_leal239405

Search Results to narrow down to complete keyword

When I do a search, I get results for All the words in the keyword field individually instead of having it narrowed down to the 'whole' of the words in the keyword field. For example, when I search for 'Aluminun Core Cone' I get all results that include any of those words. I would like to get in this case only the results that include exactly those words only.

Here's my code:

<?php
$searchWADAcac_prod_subcategory_leveltwo_NEW_WADbSearch1 = new WA_MySQLi_Search("WADAcac_prod_subcategory_leveltwo_NEW","");
if (isset($_GET["Search"]) || isset($_GET["Search_x"])) {
$searchWADAcac_prod_subcategory_leveltwo_NEW_WADbSearch1->clearSearch();
$searchWADAcac_prod_subcategory_leveltwo_NEW_WADbSearch1->setSearch(array("type"=>"Key", "comparison"=>"includes", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("prod_name", "prod_name2", "part_no"), "s", "".(isset($_GET["prod_name"])?$_GET["prod_name"]:"") ."");
}
?>

I've also attached the file. Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

This is controlled by this code:

"and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""

this says that any space is an OR and any comma-space is an AND

It also makes it so any search enclosed in quotes is treated as a whole phrase search.

so searching: this that

will return results for: 'this' OR 'that'

searching: this, that

will return results for: 'this' AND 'that'

and searching: "this that"

would return the exact match: 'this that'

You can change those settings. If you leave the and and or values blank then everything would be an exact match like:
"and"=>"", "or"=>"", "start_encap"=>"\"", "end_encap"=>"\""

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

Thanks for that awesome explanation. That's great to know. It's pretty powerful! I can work with it now.

Sign in to reply to this post

lr_leal239405

below

Attached Files
cac_prod_search.php
cac_prod_search_results.php
Sign in to reply to this post

Ray BorduinWebAssist

Let me know if you need help with this today. I'd want to do a screen share and quick phone call to make sure we were doing what you want, but I have some time today if you need it.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

I have question along the same lines on same file. I want it to return results if keywords (that include only a space) have the search keyword in either of two tables in the db. So,for example, I search for '1 inch plastic', but '1 inch' is on one table, and 'plastic' in another. It doesn't produce results when trying to do that, unless I use a comma of course, which produces too many results. Below is my code: (they body have the fields included)

Sign in to reply to this post

Ray BorduinWebAssist

I don't think that is going to be easy to pull off.

So let's say you do a search for "1 inch plastic"

How would the code know to look for "1 inch" in one column and "plastic" in the other? What not "1" and "inch plastic"? or "1" and "inch" and "plastic"? What if it finds the entire string "1 inch plastic" in the first table? What about the second? What if they type "plastic 1 inch"?

You are going to have to somehow identify what to look for in each column and what the rules are when searching. You might want to just add two fields instead of one.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

ok. thanks. Just need to let my boss know. He wants everything easy so I don't think he'll want the two search fields as he keeps pushing for less complicated and less steps to use, and wants the program to figure out what he's thinking. :)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...