close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

filtering by different table

Thread began 6/11/2015 10:03 am by Jamie | Last modified 6/15/2015 3:55 pm by Ray Borduin | 761 views | 21 replies |

Jamie

filtering by different table

Hi Ray

In the attached page, how would I get the recordset Products to filter based on a different table 'productcategories' using the column 'CatPeramlink'?

Cheers

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

I'm afraid I don't really understand your question. You are mixing terms in a way that makes it hard for me to follow. How do I filter a Recorset based on a different table? That sentence doesn't make sense to me.

Do you mean based on a different Recordset?

If you filter a Recordset, that recordset has to have a SQL statement that includes any tables you would filter in it. You can't filter a Recodset with a value from a table that the recordset doesn't have included in the recordset.

I'm not sure what you are doing, but the answer is to either add a join to the Recordset so that it has the table and columns you want to filter by, or to create another recordset to get the values you need and use that recordset to filter the next one based in its returned value.

Sign in to reply to this post

Jamie

ok, am struggling to explain it......

righy, the source page has a list of links which list out categories from a recordset (eg domain.co.uk/type/monthly-disposable where the last part is generated by the CatPermalink column in the productcategories table

When you click on the link, you get taken through to a page which, at the moment, lists all products. However, I want to filter the product results based on the category that is used in the URL (in the example the column CatPermalink - in my example monthly-disposable, but it could be another such as daily-disposable, its entirely dependent on whats in the tabel.

On the page I attached in my first post, the products are being listed by recordset 'Products' but I dont know how to then filter the results based on the URL monthly-disposable (or whatever has been created in the URL on the source page witht the CatPermalink column from the productcategories table.

Hope that perhaps explains a bit better ? :S

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

I think you would do a join in the recordset to join in the Categories table and then you could filter that based on the url parameter generated by the url.

Sign in to reply to this post

Jamie

OK, so I have got

<?php
$Products = new WA_MySQLi_RS("Products",$DBConnection,0);
$Products->setQuery("SELECT products.*, productcategories.* FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID WHERE products.ProductLive = 1 ORDER BY products.ProductOrder ASC");
$Products->execute();
?>



Not sure how I now filter by CatPermlink based on the url

Cheers

Sign in to reply to this post

Ray BorduinWebAssist

Usually your .htaccess file will translate the url into a URL parameter and then you would add the filter to the SQL statement using the $_GET parameter.

Sign in to reply to this post

Jamie

How would I structure the statement on that basis?

Sign in to reply to this post

Ray BorduinWebAssist

You would add the parameter to your WHERE clause. You might end up with:

php:
<?php

$Products 
= new WA_MySQLi_RS("Products",$DBConnection,0);
$Products->setQuery("SELECT products.*, productcategories.* FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID WHERE products.ProductLive = 1 AND ProductCategory = ? ORDER BY products.ProductOrder ASC");
$Products->bindParam("s","".($_GET['CatPermlink'])  ."""-1");
$Products->execute();
?>
Sign in to reply to this post

Jamie

thanks Ray. thats giving me an sql error which I believe is probably due to the highlighted reference here: http://prntscr.com/7g8gvp

should that be from the products or productcategories table?

I have tried replacing it with CategoryName (from productcategories) and also tried with ProductCategoryID from products but, although there is no error, no results are displayed.

Sign in to reply to this post

Ray BorduinWebAssist

Unfortunately I don't know what is in your .htaccess folder or what your exact database structure is, so I can't say what the issue is at this point.

Sign in to reply to this post
loading

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