close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

One keyword search for multiple tables?

Thread began 10/19/2009 1:34 pm by gary313807 | Last modified 7/30/2012 11:47 am by gary313807 | 3554 views | 17 replies

Dave BuchholzBeta Tester

I have implemented a one field one keyword search on T Shirt Town that searches the product, category and subcategory titles.

The search code looks like this:

//WA Database Search (Copyright 2005,

//Recordset: rsProducts;
//Searchpage: search-form.php;
//Form: frmSearch;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET["WADbSearch1"])) && ($_GET["WADbSearch1"] != "")) {
  $WADbSearch1 = new FilterDef;
  //keyword array declarations
  $KeyArr0 = array("tbl_products.title");
  $KeyArr2 = array("tbl_categories.title");
  $KeyArr3 = array("tbl_subcategories.title");

  //comparison list additions
  $WADbSearch1->keywordComparison($KeyArr0,"".((isset($_GET["zoom_query"]))?$_GET["zoom_query"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);
  $WADbSearch1->keywordComparison($KeyArr2,"".((isset($_GET["zoom_query"]))?$_GET["zoom_query"]:"")  ."","OR","Includes",",%20","%20","%22","%22",0);
  $WADbSearch1->keywordComparison($KeyArr3,"".((isset($_GET["zoom_query"]))?$_GET["zoom_query"]:"")  ."","OR","Includes",",%20","%20","%22","%22",0);

  //save the query in a session variable
  if ((isset($_GET["WADbSearch1"])) && ($_GET["WADbSearch1"] != "")) {
else     {
  $WADbSearch1 = new FilterDef;
  //get the filter definition from a session variable
  if ((isset($_GET["WADbSearch1"])) && ($_GET["WADbSearch1"] != ""))     {
    if (isset($_SESSION["WADbSearch1_tbl_products"]) && $_SESSION["WADbSearch1_tbl_products"] != "")     {
      $WADbSearch1->whereClause = $_SESSION["WADbSearch1_tbl_products"];
    else     {
      $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
  else     {
    $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';

and my recordset code looks like this:

mysql_select_db($database_connDB, $connDB);

$query_rsProducts = "SELECT tbl_categories.title AS category, tbl_categories.url AS categoryURL, tbl_subcategories.title AS subcategory, tbl_subcategories.url AS subcategoryURL, tbl_products.title AS product, tbl_products.url AS productURL, tbl_products.details AS productDetails, AS productID, tbl_products.image AS productImage, tbl_products.image2 AS productImage2, tbl_products.image3 AS productImage3, AS categoryID, AS subcategoryID, tbl_prodtypes.url AS prodtypeURL, AS prodtypeID, tbl_gender.title AS gender, tbl_gender.url AS genderURL FROM tbl_products JOIN tbl_lnkprodcatsubcat ON ( = tbl_lnkprodcatsubcat.productsID) JOIN tbl_categories ON (tbl_lnkprodcatsubcat.categoriesID = JOIN tbl_subcategories ON (tbl_lnkprodcatsubcat.subcategoriesID = JOIN tbl_lnkproductprodtypes ON (tbl_lnkprodcatsubcat.productsID = tbl_lnkproductprodtypes.productsID) JOIN tbl_prodtypes ON (tbl_lnkproductprodtypes.prodtypesID = JOIN tbl_gender ON ( = WHERE tbl_categories.publish = 1 AND tbl_subcategories.publish = 1 AND tbl_products.publish = 1 AND tbl_prodtypes.publish = 1 GROUP BY ORDER BY tbl_categories.sortorder ASC, tbl_subcategories.sortorder ASC, tbl_products.sortorder ASC, tbl_products.title DESC";
$query_limit_rsProducts = sprintf("%s LIMIT %d, %d", $query_rsProducts, $startRow_rsProducts, $maxRows_rsProducts);
$rsProducts = mysql_query($query_limit_rsProducts, $connDB) or die(mysql_error());
$row_rsProducts = mysql_fetch_assoc($rsProducts);

Hope that helps someone

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





Ease of use


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