close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

2 where clauses in data assist search

Thread began 3/01/2011 7:22 am by mr hankey | Last modified 3/03/2011 11:33 am by Jason Byrnes | 920 views | 3 replies |

mr hankey

2 where clauses in data assist search

hi,

i have tried adding in the wizard 2 where clauses as you will see from my code however it does not work. it is executing the first where clause but the second it is not. it shows the archived properties even though i want it to only show the non archived properties (= 0) (archive = 1)

here is the the php code:

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

// Make unified connection variable
$conn_cbank = new KT_connection($cbank, $database_cbank);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_cbank, "");
//Grand Levels: Level
$restrict->addLevel("1");
$restrict->Execute();
//End Restrict Access To Page
?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproperties;
//Searchpage: properties_Results.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "ProductTypeID <= 14 and Archive = 0";
if (!session_id()) session_start();
if ((isset($_GET["WADbSearch1"])) && ($_GET["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr1 = array("PropertyRef");
$KeyArr2 = array("SaleType");
$KeyArr3 = array("Country");
$KeyArr4 = array("Development");
$KeyArr5 = array("PropertyCompany");

//comparison list additions
$WADbSearch1->addComparisonFromEdit("PriceofProperty","S_PriceofProperty","AND","=",1);
$WADbSearch1->keywordComparison($KeyArr1,"".((isset($_GET["S_PropertyRef"]))?$_GET["S_PropertyRef"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr2,"".((isset($_GET["S_SaleType"]))?$_GET["S_SaleType"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->addComparisonFromEdit("ProductTypeID","S_ProductTypeID","OR","=",1);
$WADbSearch1->keywordComparison($KeyArr3,"".((isset($_GET["S_Country"]))?$_GET["S_Country"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr4,"".((isset($_GET["S_Development"]))?$_GET["S_Development"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr5,"".((isset($_GET["S_PropertyCompany"]))?$_GET["S_PropertyCompany"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_properties_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_properties_Results"]) && $_SESSION["WADbSearch1_properties_Results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_properties_Results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
<?php
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;
}
}
?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
?>
<?php
$maxRows_WADAproperties = 10;
$pageNum_WADAproperties = 0;
if (isset($_GET['pageNum_WADAproperties'])) {
$pageNum_WADAproperties = $_GET['pageNum_WADAproperties'];
}
$startRow_WADAproperties = $pageNum_WADAproperties * $maxRows_WADAproperties;

mysql_select_db($database_cbank, $cbank);
$query_WADAproperties = "SELECT PropertyID, ProductTypeID, clients_ClientID, PropertyRef, SaleType, Country, PropertyCompany, Development, PropertyType, UnitNo, PriceofProperty, ProductName, ProductDescription, Scurrency, DepositPercentage, Special, SpecialPrice, DateSpecialEnds, GMAPCommission, APCommission, PCCommission, AgentCommission, SubAgentCommission, IFAFee, SippFee, Image1, Image1path, Image2, Image2Path, Archive FROM properties ORDER BY PriceofProperty ASC";
setQueryBuilderSource($query_WADAproperties,$WADbSearch1,false);
$query_limit_WADAproperties = sprintf("%s LIMIT %d, %d", $query_WADAproperties, $startRow_WADAproperties, $maxRows_WADAproperties);
$WADAproperties = mysql_query($query_limit_WADAproperties, $cbank) or die(mysql_error());
$row_WADAproperties = mysql_fetch_assoc($WADAproperties);

if (isset($_GET['totalRows_WADAproperties'])) {
$totalRows_WADAproperties = $_GET['totalRows_WADAproperties'];
} else {
$all_WADAproperties = mysql_query($query_WADAproperties);
$totalRows_WADAproperties = mysql_num_rows($all_WADAproperties);
}
$totalPages_WADAproperties = ceil($totalRows_WADAproperties/$maxRows_WADAproperties)-1;
?>
<?php
$maxRows_WADADynListproduct_provider = 1000;
$pageNum_WADADynListproduct_provider = 0;
if (isset($_GET['pageNum_WADADynListproduct_provider'])) {
$pageNum_WADADynListproduct_provider = $_GET['pageNum_WADADynListproduct_provider'];
}
$startRow_WADADynListproduct_provider = $pageNum_WADADynListproduct_provider * $maxRows_WADADynListproduct_provider;

mysql_select_db($database_cbank, $cbank);
$query_WADADynListproduct_provider = "SELECT ProductProvider, ProductProvider FROM product_provider ORDER BY ProductProvider";
$query_limit_WADADynListproduct_provider = sprintf("%s LIMIT %d, %d", $query_WADADynListproduct_provider, $startRow_WADADynListproduct_provider, $maxRows_WADADynListproduct_provider);
$WADADynListproduct_provider = mysql_query($query_limit_WADADynListproduct_provider, $cbank) or die(mysql_error());
$row_WADADynListproduct_provider = mysql_fetch_assoc($WADADynListproduct_provider);

if (isset($_GET['totalRows_WADADynListproduct_provider'])) {
$totalRows_WADADynListproduct_provider = $_GET['totalRows_WADADynListproduct_provider'];
} else {
$all_WADADynListproduct_provider = mysql_query($query_WADADynListproduct_provider);
$totalRows_WADADynListproduct_provider = mysql_num_rows($all_WADADynListproduct_provider);
}
$totalPages_WADADynListproduct_provider = ceil($totalRows_WADADynListproduct_provider/$maxRows_WADADynListproduct_provider)-1;
?>
<?php
$queryString_WADAproperties = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_WADAproperties") == false &&
stristr($param, "totalRows_WADAproperties") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_WADAproperties = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_WADAproperties = sprintf("&totalRows_WADAproperties=%d%s", $totalRows_WADAproperties, $queryString_WADAproperties);

// Show Dynamic Thumbnail
$objDynamicThumb1 = new tNG_DynamicThumbnail("", "KT_thumbnail1");
$objDynamicThumb1->setFolder("PropImages/");
$objDynamicThumb1->setRenameRule("{WADAproperties.Image1}");
$objDynamicThumb1->setResize(250, 150, false);
$objDynamicThumb1->setWatermark(false);
$objDynamicThumb1->setPopupSize(800, 600, false);
$objDynamicThumb1->setPopupNavigation(true);
$objDynamicThumb1->setPopupWatermark(false);

// Show Dynamic Thumbnail
$objDynamicThumb1 = new tNG_DynamicThumbnail("", "KT_thumbnail1");
$objDynamicThumb1->setFolder("PropImages/");
$objDynamicThumb1->setRenameRule("{WADAproperties.Image1path}");
$objDynamicThumb1->setResize(250, 250, false);
$objDynamicThumb1->setWatermark(false);
$objDynamicThumb1->setPopupSize(800, 600, false);
$objDynamicThumb1->setPopupNavigation(false);
$objDynamicThumb1->setPopupWatermark(false);
?>

is there a way to have 2 where clauses using data assist?

thanks

Sign in to reply to this post

Jason ByrnesWebAssist

instead of adding it to the defulat where clause, add it to the main recordset:

SELECT PropertyID, ProductTypeID, clients_ClientID, PropertyRef, SaleType, Country, PropertyCompany, Development, PropertyType, UnitNo, PriceofProperty, ProductName, ProductDescription, Scurrency, DepositPercentage, Special, SpecialPrice, DateSpecialEnds, GMAPCommission, APCommission, PCCommission, AgentCommission, SubAgentCommission, IFAFee, SippFee, Image1, Image1path, Image2, Image2Path, Archive FROM properties WHERE ProductTypeID <= 14 AND Archive = 0 ORDER BY PriceofProperty ASC

Sign in to reply to this post

mr hankey

thansk jason, when changing it in the recordset this works in dreamweaver and displays the correct results however now the search function does not work.

here is code:

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

// Make unified connection variable
$conn_cbank = new KT_connection($cbank, $database_cbank);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_cbank, "");
//Grand Levels: Level
$restrict->addLevel("1");
$restrict->Execute();
//End Restrict Access To Page
?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproperties;
//Searchpage: properties_Results.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET["WADbSearch1"])) && ($_GET["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr1 = array("PropertyRef");
$KeyArr2 = array("SaleType");
$KeyArr3 = array("Country");
$KeyArr4 = array("Development");
$KeyArr5 = array("PropertyCompany");

//comparison list additions
$WADbSearch1->addComparisonFromEdit("PriceofProperty","S_PriceofProperty","AND","=",1);
$WADbSearch1->keywordComparison($KeyArr1,"".((isset($_GET["S_PropertyRef"]))?$_GET["S_PropertyRef"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr2,"".((isset($_GET["S_SaleType"]))?$_GET["S_SaleType"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->addComparisonFromEdit("ProductTypeID","S_ProductTypeID","OR","=",1);
$WADbSearch1->keywordComparison($KeyArr3,"".((isset($_GET["S_Country"]))?$_GET["S_Country"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr4,"".((isset($_GET["S_Development"]))?$_GET["S_Development"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->keywordComparison($KeyArr5,"".((isset($_GET["S_PropertyCompany"]))?$_GET["S_PropertyCompany"]:"") ."","OR","Includes",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_properties_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_properties_Results"]) && $_SESSION["WADbSearch1_properties_Results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_properties_Results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
<?php
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;
}
}
?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
?>
<?php
$maxRows_WADAproperties = 10;
$pageNum_WADAproperties = 0;
if (isset($_GET['pageNum_WADAproperties'])) {
$pageNum_WADAproperties = $_GET['pageNum_WADAproperties'];
}
$startRow_WADAproperties = $pageNum_WADAproperties * $maxRows_WADAproperties;

mysql_select_db($database_cbank, $cbank);
$query_WADAproperties = "SELECT PropertyID, ProductTypeID, clients_ClientID, PropertyRef, SaleType, Country, PropertyCompany, Development, PropertyType, UnitNo, PriceofProperty, ProductName, ProductDescription, Scurrency, DepositPercentage, Special, SpecialPrice, DateSpecialEnds, GMAPCommission, APCommission, PCCommission, AgentCommission, SubAgentCommission, IFAFee, SippFee, Image1, Image1path, Image2, Image2Path, Archive FROM properties WHERE ProductTypeID <= 14 AND Archive = 0 ORDER BY PriceofProperty ASC";
setQueryBuilderSource($query_WADAproperties,$WADbSearch1,false);
$query_limit_WADAproperties = sprintf("%s LIMIT %d, %d", $query_WADAproperties, $startRow_WADAproperties, $maxRows_WADAproperties);
$WADAproperties = mysql_query($query_limit_WADAproperties, $cbank) or die(mysql_error());
$row_WADAproperties = mysql_fetch_assoc($WADAproperties);

if (isset($_GET['totalRows_WADAproperties'])) {
$totalRows_WADAproperties = $_GET['totalRows_WADAproperties'];
} else {
$all_WADAproperties = mysql_query($query_WADAproperties);
$totalRows_WADAproperties = mysql_num_rows($all_WADAproperties);
}
$totalPages_WADAproperties = ceil($totalRows_WADAproperties/$maxRows_WADAproperties)-1;
?>
<?php
$maxRows_WADADynListproduct_provider = 1000;
$pageNum_WADADynListproduct_provider = 0;
if (isset($_GET['pageNum_WADADynListproduct_provider'])) {
$pageNum_WADADynListproduct_provider = $_GET['pageNum_WADADynListproduct_provider'];
}
$startRow_WADADynListproduct_provider = $pageNum_WADADynListproduct_provider * $maxRows_WADADynListproduct_provider;

mysql_select_db($database_cbank, $cbank);
$query_WADADynListproduct_provider = "SELECT ProductProvider, ProductProvider FROM product_provider ORDER BY ProductProvider";
$query_limit_WADADynListproduct_provider = sprintf("%s LIMIT %d, %d", $query_WADADynListproduct_provider, $startRow_WADADynListproduct_provider, $maxRows_WADADynListproduct_provider);
$WADADynListproduct_provider = mysql_query($query_limit_WADADynListproduct_provider, $cbank) or die(mysql_error());
$row_WADADynListproduct_provider = mysql_fetch_assoc($WADADynListproduct_provider);

if (isset($_GET['totalRows_WADADynListproduct_provider'])) {
$totalRows_WADADynListproduct_provider = $_GET['totalRows_WADADynListproduct_provider'];
} else {
$all_WADADynListproduct_provider = mysql_query($query_WADADynListproduct_provider);
$totalRows_WADADynListproduct_provider = mysql_num_rows($all_WADADynListproduct_provider);
}
$totalPages_WADADynListproduct_provider = ceil($totalRows_WADADynListproduct_provider/$maxRows_WADADynListproduct_provider)-1;
?>
<?php
$queryString_WADAproperties = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_WADAproperties") == false &&
stristr($param, "totalRows_WADAproperties") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_WADAproperties = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_WADAproperties = sprintf("&totalRows_WADAproperties=%d%s", $totalRows_WADAproperties, $queryString_WADAproperties);

// Show Dynamic Thumbnail
$objDynamicThumb1 = new tNG_DynamicThumbnail("", "KT_thumbnail1");
$objDynamicThumb1->setFolder("PropImages/");
$objDynamicThumb1->setRenameRule("{WADAproperties.Image1}");
$objDynamicThumb1->setResize(250, 150, false);
$objDynamicThumb1->setWatermark(false);
$objDynamicThumb1->setPopupSize(800, 600, false);
$objDynamicThumb1->setPopupNavigation(true);
$objDynamicThumb1->setPopupWatermark(false);

// Show Dynamic Thumbnail
$objDynamicThumb1 = new tNG_DynamicThumbnail("", "KT_thumbnail1");
$objDynamicThumb1->setFolder("PropImages/");
$objDynamicThumb1->setRenameRule("{WADAproperties.Image1path}");
$objDynamicThumb1->setResize(250, 250, false);
$objDynamicThumb1->setWatermark(false);
$objDynamicThumb1->setPopupSize(800, 600, false);
$objDynamicThumb1->setPopupNavigation(false);
$objDynamicThumb1->setPopupWatermark(false);
?>

Sign in to reply to this post

Jason ByrnesWebAssist

to troubleshoot, add the following code after the <body> tag:

php:
SQL: <?php echo($query_limit_WADAproperties); ?><br />



please send a link where i can see the problem.


instead of pasting the code in your message, please add the php page to a zip archive and attach the zip archive to your message so I can see the entire page code in context.

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