close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

DataAssist Search 'contains' not 'exact match'

Thread began 3/25/2016 9:33 am by gb261593 | Last modified 3/28/2016 5:21 pm by Ray Borduin | 1939 views | 8 replies |

gb261593

DataAssist Search 'contains' not 'exact match'

I have an old version of DataAssist which generally works fine. I want to carry out a check through a database 'clients' which contains (amongst other things) forename, surname and postcode.

I want to design a search where there are 2 input fields 'name' and 'postcode' and where the system checks if the forename contains the name input, or the surname contains the name input or the postcode contains the postcode input.

I have it working so it check if the surname is an exact match or the postcode is an exact match but am not sure how do do what I want. Is it possible?

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

Yes... in the search code you just have to change "=" to "Includes"... If you have difficulty finding where, send me a copy of the results page I can reference line numbers.

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

gb261593

Thank you. I tried that but it didn't seem to work so I have included the code below. I just changed two '=' signs as you can see. Any guidance would be very welcome.

Also, this example only checks if the surname field matches the surname input field. Because some names are put the other way round I wanted to check the forename field against the surname input as well. Is that possible?

The code is:

<?php
//WA Database Search Include
require_once("../../WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: rsList;
//Searchpage: conflict_check.php;
//Form: form1;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparisonFromEdit("surname","surname","AND","includes",0);
$WADbSearch1->addComparisonFromEdit("postcode","postcode","OR","includes",0);

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

<?php
// Load the tNG classes
require_once('../../includes/tng/tNG.inc.php');

// Make unified connection variable
$conn_blac = new KT_connection($blac, $database_blac);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_blac, "../../");
//Grand Levels: Level
$restrict->addLevel("9");
$restrict->Execute();
//End Restrict Access To Page

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_blac, $blac);
$query_rsList = "SELECT clientid, forename, surname, add1, add2, add3, town, postcode FROM client ORDER BY surname ASC";
setQueryBuilderSource($query_rsList,$WADbSearch1,false);
$rsList = mysql_query($query_rsList, $blac) or die(mysql_error());
$row_rsList = mysql_fetch_assoc($rsList);
$totalRows_rsList = mysql_num_rows($rsList);
?>


<table border="1">
<tr>
<td>clientid</td>
<td>forename</td>
<td>surname</td>
<td>add1</td>
<td>add2</td>
<td>add3</td>
<td>town</td>
<td>postcode</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rsList['clientid']; ?></td>
<td><?php echo $row_rsList['forename']; ?></td>
<td><?php echo $row_rsList['surname']; ?></td>
<td><?php echo $row_rsList['add1']; ?></td>
<td><?php echo $row_rsList['add2']; ?></td>
<td><?php echo $row_rsList['add3']; ?></td>
<td><?php echo $row_rsList['town']; ?></td>
<td><?php echo $row_rsList['postcode']; ?></td>
</tr>
<?php } while ($row_rsList = mysql_fetch_assoc($rsList)); ?>
</table>

Sign in to reply to this post

Ray BorduinWebAssist

Try using "Includes" with a capitol "I"... data assist is a little particular with that.

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

gb261593

Many thanks - that works fine now. Also:

This example only checks if the surname field matches the surname input field. Because some names are entered by users the other way round I wanted to check the forename field against the surname input as well. Is that possible?

Sign in to reply to this post

Ray BorduinWebAssist

Yes... open up the DataAssist Search server behavior and change the search type to "Keyword"... that will allow you to multi-select more than one column in the table to search against.

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

gb261593

Thank you but I can't find where to do this. Is it because I use an old version ie DataAssist 2.1? If not, do I do it when I first set up the search or by editing afterwards.

Sign in to reply to this post

Ray BorduinWebAssist

The results page should have the Search server behavior listed in the server behaviors panel.

To do it manually replace this code:

php:
//keyword array declarations


//comparison list additions
$WADbSearch1->addComparisonFromEdit("surname","surname","AND","includes",0);
$WADbSearch1->addComparisonFromEdit("postcode","postcode","OR","includes",0);


with this:

php:
//keyword array declarations

$KeyArr1 = array("forename", "surname");

//comparison list additions
$WADbSearch1->keywordComparison($KeyArr1,"".((isset($_POST["surname"]))?$_POST["surname"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->addComparisonFromEdit("postcode","postcode","OR","includes",0);
Sign in to reply to this post
Did this help? Tips are appreciated...

gb261593

That works perfectly - very many thanks for all of your help and being so patient.

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