close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Price range search

Thread began 10/23/2009 9:37 am by maurizio.melandri390100 | Last modified 10/28/2009 11:48 am by Eric Mittman | 3847 views | 7 replies |

maurizio.melandri390100

Price range search

I have created with data assist a form with 2 fields for price range. Form work well, but price range not work.

I tried with data assist search but not work.

I am attaching the search and page results before and after the date assists search

Attached Files
price range.zip
Sign in to reply to this post

Eric Mittman

Setting this up correctly in DataAssist Search you will need to have two criteria. One for the start and one for the end. For the first criteria you will select the price column, then for the type select Number, then for the comparison you will select less than. Finally for the type choose value, and for the value use the lightning bolt to select your min price field.

For the max price you would do the same thing but choose greater than for the comparison and select the max price input for the value.

What are the steps you have taken and what is the result you are getting?

Sign in to reply to this post

maurizio.melandri390100

Originally Said By: Eric Mittman
  Setting this up correctly in DataAssist Search you will need to have two criteria. One for the start and one for the end. For the first criteria you will select the price column, then for the type select Number, then for the comparison you will select less than. Finally for the type choose value, and for the value use the lightning bolt to select your min price field.

For the max price you would do the same thing but choose greater than for the comparison and select the max price input for the value.

What are the steps you have taken and what is the result you are getting?  



I open the page of results. I run search wizard and select the search page and the search form. I add the "range of price" and select "or". I select the column of price in the table and 2 fileds (text field) from form (minimum and maximum).

When try in IE i have this error:

Fatal error: Class 'FilterDef' not found in C:\xampp\htdocs\www\doctorhousepc\lista-prodotti-cercati.php on line 10

The page lista-prodotti-cercati from line 1 thru line 87:

<?php require_once('Connections/schede.php'); ?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAdhpc_prodotti;
//Searchpage: search.php;
//Form: WADASearchForm;
$WADbSearch2_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET["WADbSearch2"])) && ($_GET["WADbSearch2"] != "")) {
$WADbSearch2 = new FilterDef;
$WADbSearch2->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch2->addComparison("dhpc_Prezzo","".WADS_stripCurrency($_POST["S_dhpc_Prezzo"]) ."","OR",">=",1);
$WADbSearch2->addComparison("dhpc_Prezzo","".WADS_stripCurrency($_POST["S_dhpc_Prezzo2"]) ."","AND","<=",1);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch2_listaprodotticercati"]=$WADbSearch2->whereClause;
}
}
else {
$WADbSearch2 = new FilterDef;
$WADbSearch2->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch2_listaprodotticercati"]) && $_SESSION["WADbSearch2_listaprodotticercati"] != "") {
$WADbSearch2->whereClause = $_SESSION["WADbSearch2_listaprodotticercati"];
}
else {
$WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;
}
}
else {
$WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;
}
}
$WADbSearch2->whereClause = str_replace("\\''", "''", $WADbSearch2->whereClause);
$WADbSearch2whereClause = '';
?>
<?php
//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAdhpc_prodotti;
//Searchpage: search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET["Search_x"]) && $_GET["Search_x"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparisonFromList("DHPC_Descrizione_tipo","S_DHPC_Descrizione_tipo","AND","=",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Marca","S_dhpc_Marca","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Sigla","S_dhpc_Sigla","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND","<=",1);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND",">=",1);

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

Sign in to reply to this post

Eric Mittman

The error you are getting about the filterdef is because you have the include further down on the page.

Move this code to the top of the page:

php:
<?php

//WA Database Search Include
require_once("WADbSearch/HelperPHP.php");
?>



The other thing you mentioned was that you are using OR as the separator, you should use AND so that the results or exclusive to the rates you enter. If you have the two criteria separated by OR then you will get any results that are greater than the first value, or less than the second. You should have both criteria separated with the AND so that you will have values that are greater than the first entered value and less than the second entered value.

Other than this the code on the page looks like the search is setup correctly. Please make these updates and test the page out again to see if you are getting the desired result.

Sign in to reply to this post

maurizio.melandri390100

I tried again. I used both the wizard DataAssist and the wizard DataAssist search. The price range-finding fails, all other research work, but when it searches for a price range don't find any records.
this is the page of results.

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

//comparison list additions
$WADbSearch1->addComparisonFromList("DHPC_Descrizione_tipo","S_DHPC_Descrizione_tipo","AND","=",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Sigla","S_dhpc_Sigla","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND","<=",1);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND",">=",1);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_listaprodotticercati"]=$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_listaprodotticercati"]) && $_SESSION["WADbSearch1_listaprodotticercati"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_listaprodotticercati"];
}
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_WADAdhpc_prodotti = 5;
$pageNum_WADAdhpc_prodotti = 0;
if (isset($_GET['pageNum_WADAdhpc_prodotti'])) {
$pageNum_WADAdhpc_prodotti = $_GET['pageNum_WADAdhpc_prodotti'];
}
$startRow_WADAdhpc_prodotti = $pageNum_WADAdhpc_prodotti * $maxRows_WADAdhpc_prodotti;

$WADADHPC_Descrizione_tipo_WADAdhpc_prodotti = "-1";
if (isset($_GET['DHPC_Descrizione_tipo'])) {
$WADADHPC_Descrizione_tipo_WADAdhpc_prodotti = (get_magic_quotes_gpc()) ? $_GET['DHPC_Descrizione_tipo'] : addslashes($_GET['DHPC_Descrizione_tipo']);
}
mysql_select_db($database_schede, $schede);
$query_WADAdhpc_prodotti = sprintf("SELECT dhpc_tipo, dhpc_Marca, dhpc_Sigla, dhpc_Descrizione, dhpc_Descrizione_lunga, dhpc_Descrizione_negozio, dhpc_Prezzo, dhpc_Foto, DHPC_Descrizione_tipo FROM dhpc_prodotti ORDER BY dhpc_Marca ASC", GetSQLValueString($WADADHPC_Descrizione_tipo_WADAdhpc_prodotti, "text"));
setQueryBuilderSource($query_WADAdhpc_prodotti,$WADbSearch1,false);
$query_limit_WADAdhpc_prodotti = sprintf("%s LIMIT %d, %d", $query_WADAdhpc_prodotti, $startRow_WADAdhpc_prodotti, $maxRows_WADAdhpc_prodotti);
$WADAdhpc_prodotti = mysql_query($query_limit_WADAdhpc_prodotti, $schede) or die(mysql_error());
$row_WADAdhpc_prodotti = mysql_fetch_assoc($WADAdhpc_prodotti);

if (isset($_GET['totalRows_WADAdhpc_prodotti'])) {
$totalRows_WADAdhpc_prodotti = $_GET['totalRows_WADAdhpc_prodotti'];
} else {
$all_WADAdhpc_prodotti = mysql_query($query_WADAdhpc_prodotti);
$totalRows_WADAdhpc_prodotti = mysql_num_rows($all_WADAdhpc_prodotti);
}
$totalPages_WADAdhpc_prodotti = ceil($totalRows_WADAdhpc_prodotti/$maxRows_WADAdhpc_prodotti)-1;
?>
<?php
$maxRows_WADADynListdhpc_prodotti = 1000;
$pageNum_WADADynListdhpc_prodotti = 0;
if (isset($_GET['pageNum_WADADynListdhpc_prodotti'])) {
$pageNum_WADADynListdhpc_prodotti = $_GET['pageNum_WADADynListdhpc_prodotti'];
}
$startRow_WADADynListdhpc_prodotti = $pageNum_WADADynListdhpc_prodotti * $maxRows_WADADynListdhpc_prodotti;

mysql_select_db($database_schede, $schede);
$query_WADADynListdhpc_prodotti = "SELECT DHPC_Descrizione_tipo, DHPC_Descrizione_tipo FROM dhpc_prodotti ORDER BY dhpc_Marca";
$query_limit_WADADynListdhpc_prodotti = sprintf("%s LIMIT %d, %d", $query_WADADynListdhpc_prodotti, $startRow_WADADynListdhpc_prodotti, $maxRows_WADADynListdhpc_prodotti);
$WADADynListdhpc_prodotti = mysql_query($query_limit_WADADynListdhpc_prodotti, $schede) or die(mysql_error());
$row_WADADynListdhpc_prodotti = mysql_fetch_assoc($WADADynListdhpc_prodotti);

if (isset($_GET['totalRows_WADADynListdhpc_prodotti'])) {
$totalRows_WADADynListdhpc_prodotti = $_GET['totalRows_WADADynListdhpc_prodotti'];
} else {
$all_WADADynListdhpc_prodotti = mysql_query($query_WADADynListdhpc_prodotti);
$totalRows_WADADynListdhpc_prodotti = mysql_num_rows($all_WADADynListdhpc_prodotti);
}
$totalPages_WADADynListdhpc_prodotti = ceil($totalRows_WADADynListdhpc_prodotti/$maxRows_WADADynListdhpc_prodotti)-1;
?>
<?php
$queryString_WADAdhpc_prodotti = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_WADAdhpc_prodotti") == false &&
stristr($param, "totalRows_WADAdhpc_prodotti") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_WADAdhpc_prodotti = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_WADAdhpc_prodotti = sprintf("&totalRows_WADAdhpc_prodotti=%d%s", $totalRows_WADAdhpc_prodotti, $queryString_WADAdhpc_prodotti);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Sign in to reply to this post

Eric Mittman

In your code it looks like you are using the same input for the value of both search criteria:

$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND","<=",1);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND",">=",1);



This will not give you any results because you are saying, 'give me the values from this column where S_dhpc_Prezzo is less then or equal to the value in the db, AND where S_dhpc_Prezzo is greater than or equal to the value'. This does not make sense and will not yield any results for you. Instead you must have two separate form elements, one for the minimum value and another for the max value. Use the max value one with the <= criteria, and the minimum value one for the >= criteria.

Sign in to reply to this post

maurizio.melandri390100

Originally Said By: Eric Mittman
  In your code it looks like you are using the same input for the value of both search criteria:

$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND","<=",1);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND",">=",1);


This will not give you any results because you are saying, 'give me the values from this column where S_dhpc_Prezzo is less then or equal to the value in the db, AND where S_dhpc_Prezzo is greater than or equal to the value'. This does not make sense and will not yield any results for you. Instead you must have two separate form elements, one for the minimum value and another for the max value. Use the max value one with the <= criteria, and the minimum value one for the >= criteria.  



I had not seen. I know a little PHP. I have corrected, but there is no improvement, unfortunately...
This is my forms (building with DataAssist)

<form action="lista-prodotti-cercati.php" method="get" name="WADASearchForm" id="WADASearchForm">
<div class="WADAHeader">Search</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">DHPC_Descrizione_tipo:</th>
<td class="WADADataTableCell">
<select name="S_DHPC_Descrizione_tipo" id="S_DHPC_Descrizione_tipo">
<?php
do {
?>
<option value="<?php echo $row_WADADynListdhpc_prodotti['DHPC_Descrizione_tipo']?>"><?php echo $row_WADADynListdhpc_prodotti['DHPC_Descrizione_tipo']?></option>
<?php
} while ($row_WADADynListdhpc_prodotti = mysql_fetch_assoc($WADADynListdhpc_prodotti));
$rows = mysql_num_rows($WADADynListdhpc_prodotti);
if($rows > 0) {
mysql_data_seek($WADADynListdhpc_prodotti, 0);
$row_WADADynListdhpc_prodotti = mysql_fetch_assoc($WADADynListdhpc_prodotti);
}
?>
</select>
</td>
</tr>
<tr>
<th class="WADADataTableHeader">dhpc_Sigla:</th>
<td class="WADADataTableCell"><input type="text" name="S_dhpc_Sigla" id="S_dhpc_Sigla" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">dhpc_Prezzo:</th>
<td class="WADADataTableCell"><input type="text" name="S_dhpc_Prezzo" id="S_dhpc_Prezzo" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">dhpc_Prezzo:</th>
<td class="WADADataTableCell"><input type="text" name="S_dhpc_Prezzo2" id="S_dhpc_Prezzo2" value="" size="32" /></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Search" id="Search" value="Search" alt="Search" src="WA_DataAssist/images/Pacifica/Refined_search.gif" /></td>
</tr>
</table>
</div>
</form>



This is the correct statement.

//comparison list additions
$WADbSearch1->addComparisonFromList("DHPC_Descrizione_tipo","S_DHPC_Descrizione_tipo","AND","=",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Sigla","S_dhpc_Sigla","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo","AND","<=",1);
$WADbSearch1->addComparisonFromEdit("dhpc_Prezzo","S_dhpc_Prezzo2","AND",">=",1);



The results is: No results for your search, but i have records for the condition :(

Sign in to reply to this post

Eric Mittman

Thanks for the effort on this, I can tell that you are trying a few things to get the desired result. I have opened a ticket for you so that we can exchange some files and do some testing with your data. To update the ticket please login to the site and go to your support history.

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