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
![](/forums/attachments/68709/cache/var/www/vhosts/webassist.com/user_uploads/forums/attachments/68709/proportion/Screen%20shot%202010-07-26%20at%2012.49.02%20PM_w101_h100/Screen%20shot%202010-07-26%20at%2012.49.02%20PM_11170737.jpg)
![](/forums/attachments/68709/cache/var/www/vhosts/webassist.com/user_uploads/forums/attachments/68709/proportion/Screen%20shot%202010-07-26%20at%2012.49.30%20PM_w101_h100/Screen%20shot%202010-07-26%20at%2012.49.30%20PM_11170737.jpg)
![](/forums/attachments/68709/cache/var/www/vhosts/webassist.com/user_uploads/forums/attachments/68709/proportion/Screen%20shot%202010-07-26%20at%2012.49.46%20PM_w100_h100/Screen%20shot%202010-07-26%20at%2012.49.46%20PM_11170737.jpg)
![](/forums/attachments/68709/cache/var/www/vhosts/webassist.com/user_uploads/forums/attachments/68709/proportion/Screen%20shot%202010-07-26%20at%2012.50.01%20PM_w100_h100/Screen%20shot%202010-07-26%20at%2012.50.01%20PM_11170737.jpg)