close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Advanced Search

Thread began 10/14/2017 1:25 pm by markdoyle87077 | Last modified 10/17/2017 1:56 pm by Ray Borduin | 49 views | 4 replies |

markdoyle87077

Advanced Search

Hi Ray,

We worked through this together on a premium ticket and it works fine

<?php
$searchrs_products_WADbSearch1 = new WA_MySQLi_Search("rs_products","");
if (isset($_SESSION["keywords"])) {
$searchrs_products_WADbSearch1->clearSearch();
$searchrs_products_WADbSearch1->setSearch(array("type"=>"k", "comparison"=>"like", "join"=>"and", "and"=>" ", "or"=>", ", "end_encap"=>"'", "start_encap"=>"'"),array("products.itemnumber", "products.supplieritemnumber", "products.description", "products.german_description", "products.supplier", "products.barcode"),"c",$_SESSION["keywords"]);
}
?>
<?php
$rs_products = new WA_MySQLi_RS("rs_products",$dmbc_database,200);
$rs_products->setQuery("SELECT id, itemnumber, german_description, selling_quantity, stockstatus, stock, packed FROM products ORDER BY description ASC");
$rs_products->execute();
?>

I now want to use CONCAT(suppler, ' ', description) AS search1 in the recordset so that I can search for products by supplier and description so I have modified the code to:

<?php
$searchrs_products_WADbSearch1 = new WA_MySQLi_Search("rs_products","");
if (isset($_SESSION["keywords"])) {
$searchrs_products_WADbSearch1->clearSearch();
$searchrs_products_WADbSearch1->setSearch(array("type"=>"k", "comparison"=>"like", "join"=>"and", "and"=>" ", "or"=>", ", "end_encap"=>"'", "start_encap"=>"'"),array("products.itemnumber", "products.supplieritemnumber", "products.description", "products.german_description", "products.supplier", "products.barcode", "products.search1"),"c",$_SESSION["keywords"]);
}
?>
<?php
$rs_products = new WA_MySQLi_RS("rs_products",$dmbc_database,200);
$rs_products->setQuery("SELECT CONCAT(supplier, description) AS search1, id, itemnumber, description, german_description, selling_quantity, stockstatus, stock, packed FROM products ORDER BY description ASC");
$rs_products->execute();
?>

When I search for products PHP throws an error:

SELECT CONCAT(supplier, description) AS search1, id, itemnumber, description, german_description, selling_quantity, stockstatus, stock, packed FROM products WHERE ((`products`.`itemnumber` like ? AND `products`.`itemnumber` like ?) OR (`products`.`supplieritemnumber` like ? AND `products`.`supplieritemnumber` like ?) OR (`products`.`description` like ? AND `products`.`description` like ?) OR (`products`.`german_description` like ? AND `products`.`german_description` like ?) OR (`products`.`supplier` like ? AND `products`.`supplier` like ?) OR (`products`.`barcode` like ? AND `products`.`barcode` like ?) OR (`products`.`search1` like ? AND `products`.`search1` like ?)) ORDER BY description ASC

Unknown column 'products.search1' in 'where clause'

Can you help me resolve this.

Sign in to reply to this post

Ray BorduinWebAssist

You would only need to add the concat() to the select statement if you wanted to display that value. To add it to the search you can just add it to the array of columns searched. It already has supplier and description in the field list:

$searchrs_products_WADbSearch1->setSearch(array("type"=>"k", "comparison"=>"like", "join"=>"and", "and"=>" ", "or"=>", ", "end_encap"=>"'", "start_encap"=>"'"),array("products.itemnumber", "products.supplieritemnumber", "products.description", "products.german_description", "products.supplier", "products.barcode"),"c",$_SESSION["keywords"]);

So you shouldn't need to add anything to it to find results from the supplier and description fields.

Sign in to reply to this post

markdoyle87077

Hi Ray,

I understand what you are saying but let us say that I am searching for products from a particular supplier then the results are not found, for example 'Pioneer ribbon' I can search individually for these terms, either the supplier 'Pioneer' or something that would be found in the product description 'Ribbon' and that is why I though about using CONCAT() in the recordset. Is it possible to do get results for products from a particular supplier using search; I am fairly sure I had this running like this using DataAssist when my site was coded in ASP.

Kind regards.

Sign in to reply to this post

Ray BorduinWebAssist

Try adding the concat to the array instead of the select like:

$searchrs_products_WADbSearch1->setSearch(array("type"=>"k", "comparison"=>"like", "join"=>"and", "and"=>" ", "or"=>", ", "end_encap"=>"'", "start_encap"=>"'"),array("products.itemnumber", "products.supplieritemnumber", "products.description", "products.german_description", "products.supplier", "products.barcode", "CONCAT(supplier, description)"),"c",$_SESSION["keywords"]);

Sign in to reply to this post

markdoyle87077

Worked a treat, thank you.

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