close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Using Check Boxes to Search

Thread began 1/04/2010 4:56 am by karen.marley367377 | Last modified 1/27/2010 9:47 am by karen.marley367377 | 1675 views | 4 replies

karen.marley367377

Using Check Boxes to Search

Hi,
I have a table column in the database which holds more than one value (i.e, value 1, value 2, value 3)

In the search box I am using check boxes where I want the user to be able to view more than one value (value 1 and/or value 2, and/or value 3)
Currently, using the syntax below, the results will show results where all values are included, but not those where just one is included (hope this makes sense!)

An example of this can be viewed at:
v_properties_Results.php


<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproperties;
//Searchpage: properties_Search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((((isset($_GET["submit"]))?$_GET["submit"]:"") != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Assembly"]))?$_GET["Assembly"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["HealthDay"]))?$_GET["HealthDay"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Industrial"]))?$_GET["Industrial"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Investment"]))?$_GET["Investment"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Land"]))?$_GET["Land"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Licenced"]))?$_GET["Licenced"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Mixed"]))?$_GET["Mixed"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Motor"]))?$_GET["Motor"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Office"]))?$_GET["Office"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Residential"]))?$_GET["Residential"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Retail"]))?$_GET["Retail"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Storage"]))?$_GET["Storage"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("RegionName","".((isset($_GET["region"]))?$_GET["region"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("SaleORLease","".((isset($_GET["status"]))?$_GET["status"]:"") ."","AND","=",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 = "")
{
$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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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 = 5;
$pageNum_WADAproperties = 0;
if (isset($_GET['pageNum_WADAproperties'])) {
$pageNum_WADAproperties = $_GET['pageNum_WADAproperties'];
}
$startRow_WADAproperties = $pageNum_WADAproperties * $maxRows_WADAproperties;

mysql_select_db($database_DBNAME, $DBNAME);
$query_WADAproperties = "SELECT MainPropertiesID, MainPropertiesIDold, SLNNumberID, FirstName, LastName, Company, PropertyType, SaleORLease, RegionName, Address1, Address2, Address3, City, County, PostCode, Country, ThumbPath, Thumb, PicturePath, Picture, AgentLogo, PropertyDetails, `Size`, Sep, SizeMax, SizeType, shortDescription, longdescription, CURR, PriceDetails, RentalPeriod, Price, Status FROM properties WHERE Status = 'Approved' ORDER BY City 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, $marle662) 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;

Your help is appreciated!

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