close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

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 gb261593 | 1938 views | 8 replies

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>

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