close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Search doesn't filter

Thread began 3/23/2014 9:31 pm by mrs | Last modified 4/17/2014 9:59 am by Jason Byrnes | 719 views | 12 replies |

mrs

Search doesn't filter

I've built a page with a recordset in it, a search box and an area for displaying filtered results returned.

I then ran the dataassist search wizard and made the page post to itself, but it doesn't work. I am still seeing all results!

What has happened? What have I done wrong? I don't think the wizard has picked up the names of the elements that I have used as WADbSearch1 seems to be used in the search code, but I don't why!

Page is attached.

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

the page you sent to me is named:
distributors2.php

but the form is set to post to a differently named page:
<form id="form1" name="form1" method="post" action="distributors.php">

Sign in to reply to this post

mrs

Ah, yes, I can see how that might be confusing... I made a copy of the page and removed a load of unnecessary code so it would be easier for you to look at, hence the file name having 2 on it.

With all of the code that I did have there, it didn't work. Basically, the page I have uploaded here is a trimmed down version of the original which isn't working, and submitting a search from distributors2.php still doesn't filter out unwanted data on disttributors.php, so I think there is a bit more to this than having an incorrect file name. I can't see what it is though. I've compared this code to other searches that do work, but nothing is obvious to me.

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

mrs

OK, after starting with a completely blank page other than my recordset for the search to work with, I allowed the search wizard to create the search form and its related fields for me. I then pasted my code to display the search results. So, now I have got a very plain page.

When I test it with something very specific, all records still seem to display based on the settings I used within the wizard. I have asked the wizard to use OR instead of AND, however, if I change the code to AND, the search then works… why?

I am asking it to look in 6 columns of a database table and return results related to the search parameter where one or more of the columns need to match to ensure that the record is displayed in the result, so surely this is a reason to use OR.

Is 'OR' saying match col1 OR col2 OR col3 OR col4 OR col5 OR col6 and show any record that does actually contain the text searched for whereas 'AND' is saying all cols must match before a record displays?

I simply changed:
$WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["distsearch"]))?$_POST["distsearch"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);

to

$WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["distsearch"]))?$_POST["distsearch"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);

for it to work.

Have I completely misunderstood the purpose between OR and AND in a search?

Sign in to reply to this post

mrs

OK, further to my previous reply, I now have it working for the most part.

What is happening now is if I search for distributors in the United States of America, then I am getting records returned that are also from the United Kingdom… the common word being 'United'… how do I stop this from happening?

And again, if you could clarify what the differences are between an AND search and an OR search, that would be helpful to me to see if I understand them correctly.

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

Please provide a Skype username or a US phone number and a good time to contact you when you will be in front of your computer and we will have an engineer contact you to resolve this issue over the phone.

We are available Monday - Friday from 9am - 4pm EST (except major U.S. holidays).

Sign in to reply to this post

mrs

Skype name in private message… we have talked before over Skype, so I should be in your contacts list

Sign in to reply to this post

Jason ByrnesWebAssist

see PM

Sign in to reply to this post

mrs

Hi Jason, hope you're well.

I still have the problem with the search on the distributors page returning results that shouldn't be returned. I've now added a jQuery autocomplete to the search box, so when you type you get a prompt of the matching database content. If I click on one of the autocomplete results, very specific content appears in the search box, content that only matches one record, however when that is submitted, I am still getting multiple, unrelated results appear in my search results.

Why is this?

I am currently out of the office a lot as I am contracting in-house for another company, so I am not able to do Skype very easily… sorry about this!

Presumptuous of me I know, but if you can't log on to my server using the previously provided details, here's my search code:

$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr0 = array("fld_dNAME", "fld_dCOUNTRY", "fld_dAREA", "fld_dADDRESS");

//comparison list additions
$WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["distsearch"]))?$_POST["distsearch"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_disttest"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_disttest"]) && $_SESSION["WADbSearch1_disttest"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_disttest"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';




and here's my search box code:

<form name="distform" action="distributors.php" method="post">
<input name="distsearch" type="text" class="distsearchbox" id="distsearch" placeholder="Start to type here to locate distributors..." value="">
<input name="WADbSearch1" type="submit" class="distsearchbtn" value="Go" style="padding:7px 20px">
</form>



I'm assuming that I have my search set to match any individual word in the search box rather than the complete phrase entered.

Sign in to reply to this post
loading

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...