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

Building a Dynamic Where Clause

Thread began 8/13/2010 10:47 am by dnys04173367569 | Last modified 8/23/2010 11:30 am by dnys04173367569 | 859 views | 3 replies


Building a Dynamic Where Clause

Problem - I wish to use a filter within the results page - i.e. Dropdown List - to allow selection of products by price range. Once the search has been made or result page loaded.

if (isset($_GET["ProductOccasionID"]) && isset($_GET["Search"])) {
if ($WADbSearch1->whereClause != "") {
$WADbSearch1->whereClause .= " AND ";
$WADbSearch1->whereClause .= "ProductID IN (SELECT ProductID FROM productoccasions WHERE (OccasionID = ".implode($_GET["ProductOccasionID"]," OR OccasionID = ")."))";

If I manually alter the line as follows:-

$WADbSearch1->whereClause .= " AND (ProductPrice >= 10.00) & (ProductPrice <= 25.00) AND ProductID IN (SELECT ProductID FROM productoccasions WHERE (OccasionID = ".implode($_GET["ProductOccasionID"]," OR OccasionID = ")."))";

The data is selected as requested. However, I need this to be dynamic for the filter to work properly.

I am trying to get the whereclause to include a $price_query string. Something like

$WADbSearch1->whereClause .= $price_query . "ProductID IN (SELECT ProductID FROM productoccasions WHERE (OccasionID = ".implode($_GET["ProductOccasionID"]," OR OccasionID = ")."))";

Whereby $price_query holds the text element " AND (ProductPrice >= 10.00) & (ProductPrice <= 25.00) AND " and gets appended in front of the Original whereClause text ProductID IN (SELECT ProductID FROM productoccasions WHERE (OccasionID = ".implode($_GET["ProductOccasionID"]," OR OccasionID = ")."))

But the Text held in $price_query is not being appended to my whereClause search. Any help would be welcome.

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