close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Please help with datasearch

Thread began 5/24/2012 4:54 am by info364504 | Last modified 5/24/2012 9:54 am by info364504 | 1225 views | 5 replies

info364504

Please help with datasearch

Hi, I have created a search by keywords facility.
The problem is it searches by any of the entered words instead of b all of them i.e:
if I search for houses in London, it will return results for houses and esults for all types of properties in London.
Here's my code:
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: buscar_palabras_RS;
//Searchpage: buscaPalabras.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
$KeyArr0 = array("regimen", "localidad", "isla", "tipopropiedad", "zona", "habitaciones", "estado", "metros", "descripcion", "precio", "precio_oferta");

//comparison list additions
$WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["buscarField"]))?$_POST["buscarField"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_buscador_palabras"]=$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_buscador_palabras"]) && $_SESSION["WADbSearch1_buscador_palabras"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_buscador_palabras"];
}
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;
}
}

$maxRows_buscar_palabras_RS = 10;
$pageNum_buscar_palabras_RS = 0;
if (isset($_GET['pageNum_buscar_palabras_RS'])) {
$pageNum_buscar_palabras_RS = $_GET['pageNum_buscar_palabras_RS'];
}
$startRow_buscar_palabras_RS = $pageNum_buscar_palabras_RS * $maxRows_buscar_palabras_RS;

mysql_select_db($database_MySQLconnect, $MySQLconnect);
$query_buscar_palabras_RS = "SELECT * FROM t_propiedades";
setQueryBuilderSource($query_buscar_palabras_RS,$WADbSearch1,false);
$query_limit_buscar_palabras_RS = sprintf("%s LIMIT %d, %d", $query_buscar_palabras_RS, $startRow_buscar_palabras_RS, $maxRows_buscar_palabras_RS);
$buscar_palabras_RS = mysql_query($query_limit_buscar_palabras_RS, $MySQLconnect) or die(mysql_error());
$row_buscar_palabras_RS = mysql_fetch_assoc($buscar_palabras_RS);

if (isset($_GET['totalRows_buscar_palabras_RS'])) {
$totalRows_buscar_palabras_RS = $_GET['totalRows_buscar_palabras_RS'];
} else {
$all_buscar_palabras_RS = mysql_query($query_buscar_palabras_RS);
$totalRows_buscar_palabras_RS = mysql_num_rows($all_buscar_palabras_RS);
}
$totalPages_buscar_palabras_RS = ceil($totalRows_buscar_palabras_RS/$maxRows_buscar_palabras_RS)-1;
?>

Thanks for your help

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