close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Search multiple fields

Thread began 7/26/2010 11:00 am by robcorrick409194 | Last modified 8/05/2010 11:34 am by Jason Byrnes | 3480 views | 19 replies |

robcorrick409194

Search multiple fields

I have read several threads about searching multiple columns, but have not been successful. I would like to search more than one column from one input search field. I have set up a DataAssist search page with the wizard. The search function works well so far when I input a search parameter in a form fields set up by the Wizard. But it does not work with my new field. I have tried adding a behavior.

The first odd thing is that there is no dataset in the server behavior, but perhaps this is not necessary with the Search Form. So I created one. All of my columns show up nicely. I then add a set of queries. The setup looks like the images below. I am trying to to a search from S_UserCategories on three fields in my database: Category1, Category2, and Category3. When I click on Search, all of the records in the database are found, just as if no search parameter was entered, suggesting that I am not passing my parameter to the search function. Can you tell me how to do this correctly? Thanks. Great software so far.

Here is the code:
<?php require_once('Connections/localhost.php'); ?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: Recordset1;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "0=0";
if (!session_id()) session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparison("Category1","".((isset($_GET["S_UserCategories"]))?$_GET["S_UserCategories"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("Category2","".((isset($_GET["S_UserCategories"]))?$_GET["S_UserCategories"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("Category3","".((isset($_GET["S_UserCategories"]))?$_GET["S_UserCategories"]:"") ."","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_users_Search"]=$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_users_Search"]) && $_SESSION["WADbSearch1_users_Search"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_users_Search"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereCla

Sign in to reply to this post

Jason ByrnesWebAssist

the DataAssist search behavior should be applied to the Results page, make sure you are not applying the search behavior to the search page.

To create a search criteria that will search more than one database column from a single search input box,, change the search type from value to Keyword. This will allow you to select multiple columns to search.

Sign in to reply to this post

robcorrick409194

Search Multiple fields. On Results page now.

Jason,

Thanks for telling me to put the search behaviors on the Results page and not the Search page. I have done this, as well as creating a key word behavior searching three columns per your suggestion. I am trying to do a multi-column search from one search field. I am still getting a blank result. In fact, when I create the new behavior, I get no search results from any field, so I am clearly doing something wrong.

Shots of the behavior windows are below. Please let me know if you need the code.

Is there something that I need to do to bind the new field in the Search form? I could not find anywhere to do this in the Server Behaviors related to the Search or Results pages.

Using DR CS5 Mac.

Bob

Sign in to reply to this post

robcorrick409194

Changing search parameters

I am following up to my last thread, which has not be answered. Can someone please help me with this issue of changing my search parameters to include multiple fields. The standard functionality of Data Assist does not seem to have key word searches, and multiple field searches. Using the Wizard, I seem to be able to search only one field at a time. I almost have my website functional but for this big issue. It will be a great testimonial to the effectiveness of DA's extension software. Very impressive.

Sign in to reply to this post

Jason ByrnesWebAssist

Can you please post a copy of the search and results page so I can examine the code.

Sign in to reply to this post

robcorrick409194

Multiple Field Search

Jason,

I have used Data Assist Wizard to create the Results and Search pages. I have added about 15 fields to the Users Registration Profile, which makes up my primary database. These fields have been included in the Search page. I would now like to simplify the Search page by combining fields; that is, use one input search field to search in multiple columns in my database. In this example, I created a new input search field named S_Categories2, which I would like to query three fields: Category1, Category2, and Category 3. The coding for the Category1-2-3 search for the results page is below. The search page is in a following thread. (Eventually I would like also to have a key word search on all of the fields. )

My searches work fine using the fields created by the wizard. The search even works when I change from Edit mode to Value mode, and create a "Yes" filter on one of my fields. I receive a blank result, however, when I add the last key word query of Category1, 2 and 3.

I still wonder whether I should be binding the new filed somewhere, but I cannot seem to find anywhere to do this.

Thanks for you help.

RESULTS PAGE CODE:
<?php require_once('Connections/localhost.php'); ?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAusers;
//Searchpage: users_Search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET["Search"]) && $_GET["Search"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr1 = array("Category1", "Category2", "Category3");

//comparison list additions
$WADbSearch1->addComparisonFromEdit("UserCity","S_UserCity","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("UserState","S_UserState","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("UserCountry","S_UserCountry","AND","Includes",0);
$WADbSearch1->addComparison("Role","Yes","AND","=",0);
$WADbSearch1->addComparisonFromEdit("Role2","S_Role2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("CareerSummary","S_CareerSummary","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Communications","S_Communications","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("AgePref","S_AgePref","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("LifeSummary","S_LifeSummary","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("PersonalExperience","S_PersonalExperience","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Category1","S_Category1","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Category2","S_Category2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Category3","S_Category3","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("OrgType1","S_OrgType1","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("OrgType2","S_OrgType2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("OrgType3","S_OrgType3","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("OrgTypesOther","S_OrgTypesOther","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("JobFunct1","S_JobFunct1","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("JobFunct2","S_JobFunct2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("JobFunct3","S_JobFunct3","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("JobFunctOther","S_JobFunctOther","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("JobTitles","S_JobTitles","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Position1","S_Position1","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Position2","S_Position2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("Position3","S_Position3","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("MentorTopic1","S_MentorTopic1","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("MentorTopic2","S_MentorTopic2","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("MentorTopic3","S_MentorTopic3","AND","Includes",0);
$WADbSearch1->keywordComparison($KeyArr1,"S_Categories2","AND","=",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_users_Results"]=$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_users_Results"]) && $_SESSION["WADbSearch1_users_Results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_users_Results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
<?php

Sign in to reply to this post

robcorrick409194

Search Page Multiple Fields

Search Page Code:

</div>
<div class="WADASearchContainer">
<form action="users_Results.php" method="get" name="WADASearchForm" id="WADASearchForm">

<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Search by Category</th>
<td class="WADADataTableCell"><input type="text" name="S_Categories2" id="S_Categories2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">City</th>
<td class="WADADataTableCell"><input type="text" name="S_UserCity" id="S_UserCity" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">State</th>
<td class="WADADataTableCell"><input type="text" name="S_UserState" id="S_UserState" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Country:</th>
<td class="WADADataTableCell"><input type="text" name="S_UserCountry" id="S_UserCountry" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Role:</th>
<td class="WADADataTableCell"><input type="text" name="S_Role" id="S_Role" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Role2:</th>
<td class="WADADataTableCell"><input type="text" name="S_Role2" id="S_Role2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">CareerSummary:</th>
<td class="WADADataTableCell"><input type="text" name="S_CareerSummary" id="S_CareerSummary" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Communications:</th>
<td class="WADADataTableCell"><input type="text" name="S_Communications" id="S_Communications" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">AgePref:</th>
<td class="WADADataTableCell"><input type="text" name="S_AgePref" id="S_AgePref" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">LifeSummary:</th>
<td class="WADADataTableCell"><input type="text" name="S_LifeSummary" id="S_LifeSummary" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">PersonalExperience:</th>
<td class="WADADataTableCell"><input type="text" name="S_PersonalExperience" id="S_PersonalExperience" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Category1:</th>
<td class="WADADataTableCell"><input type="text" name="S_Category1" id="S_Category1" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Category2:</th>
<td class="WADADataTableCell"><input type="text" name="S_Category2" id="S_Category2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Category3:</th>
<td class="WADADataTableCell"><input type="text" name="S_Category3" id="S_Category3" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">OrgType1:</th>
<td class="WADADataTableCell"><input type="text" name="S_OrgType1" id="S_OrgType1" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">OrgType2:</th>
<td class="WADADataTableCell"><input type="text" name="S_OrgType2" id="S_OrgType2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">OrgType3:</th>
<td class="WADADataTableCell"><input type="text" name="S_OrgType3" id="S_OrgType3" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">OrgTypesOther:</th>
<td class="WADADataTableCell"><input type="text" name="S_OrgTypesOther" id="S_OrgTypesOther" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">JobFunct1:</th>
<td class="WADADataTableCell"><input type="text" name="S_JobFunct1" id="S_JobFunct1" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">JobFunct2:</th>
<td class="WADADataTableCell"><input type="text" name="S_JobFunct2" id="S_JobFunct2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">JobFunct3:</th>
<td class="WADADataTableCell"><input type="text" name="S_JobFunct3" id="S_JobFunct3" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">JobFunctOther:</th>
<td class="WADADataTableCell"><input type="text" name="S_JobFunctOther" id="S_JobFunctOther" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">JobTitles:</th>
<td class="WADADataTableCell"><input type="text" name="S_JobTitles" id="S_JobTitles" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">MentorTopic1:</th>
<td class="WADADataTableCell"><input type="text" name="S_MentorTopic1" id="S_MentorTopic1" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">MentorTopic2:</th>
<td class="WADADataTableCell"><input type="text" name="S_MentorTopic2" id="S_MentorTopic2" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">MentorTopic3:</th>
<td class="WADADataTableCell"><input type="text" name="S_MentorTopic3" id="S_MentorTopic3" value="" size="32" /></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="Submit" name="Search" id="Search" value="Search" /></td>
</tr>
</table>
</div>
</form>
</div>

Sign in to reply to this post

robcorrick409194

Full Files

Jason,

In case this makes it easier for you, attached are complete copies of the Search and Results pages.

Sign in to reply to this post

Jason ByrnesWebAssist

can you provide a link where I could test the search and results to see the issue.

also, i will need you to compress the search and results files into a zip archive and send the zip file in your reply.

Sign in to reply to this post

robcorrick409194

Search Multiple Fields

Here are the Search and Results pages both from Dreamweaver php and rtf files. You can see these pages in operation at users_Search2.php. This search brings the blank result.

If you go to users_Search.php. The search works well. This search does not have the key word search in it.

Attached Files
Search & Results Pages.zip
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...