I am trying to do something fairly simple.
I have two pages. Brands.php and Products.php.
When I click on Brands.php it takes me to a list of Brands. I click on a brand, for example, brand1.php. From there I can choose a category - Category1.
Category1 needs to go to store.php?Brand ID=1&CatID=1. At this point I have only got it to filter by either or... either BrandID or CatID. So I go to store.php?Brand ID=1, I get all items that are under Brand1, and similarly, when I go to CatID=1, I get all items that are under category1.
The problem is that I cannot get it to filter by BrandID and CatID together. I need something of a combination of the AND/OR fuction in SQL.
At this point here is what I have:
SELECT *
FROM products
WHERE BrandID = colname OR CatID = colname2
I have two variables defined: colname and colname2.
Name: colname
Type: Numeric
Default value: -1
Run-time Value: $_GET['BrandID']
Name: colname2
Type: Numeric
Default value: -1
Run-time Value: $_GET['CatID']
This is successfully doing what I have described above, but I need it to filter by each one individually AND both together.
I have tried:
SELECT *
FROM products
WHERE (BrandID = colname OR CatID = colname2) OR (BrandID= colname AND CatID = colname2)
but it did not succeed. Do I need to add a new colname3, perhaps?
I am using Dreamweaver's Advanced Recordset.
Your help and detailed answer will be greatly appreciated!
Thanks!
I have two pages. Brands.php and Products.php.
When I click on Brands.php it takes me to a list of Brands. I click on a brand, for example, brand1.php. From there I can choose a category - Category1.
Category1 needs to go to store.php?Brand ID=1&CatID=1. At this point I have only got it to filter by either or... either BrandID or CatID. So I go to store.php?Brand ID=1, I get all items that are under Brand1, and similarly, when I go to CatID=1, I get all items that are under category1.
The problem is that I cannot get it to filter by BrandID and CatID together. I need something of a combination of the AND/OR fuction in SQL.
At this point here is what I have:
SELECT *
FROM products
WHERE BrandID = colname OR CatID = colname2
I have two variables defined: colname and colname2.
Name: colname
Type: Numeric
Default value: -1
Run-time Value: $_GET['BrandID']
Name: colname2
Type: Numeric
Default value: -1
Run-time Value: $_GET['CatID']
This is successfully doing what I have described above, but I need it to filter by each one individually AND both together.
I have tried:
SELECT *
FROM products
WHERE (BrandID = colname OR CatID = colname2) OR (BrandID= colname AND CatID = colname2)
but it did not succeed. Do I need to add a new colname3, perhaps?
I am using Dreamweaver's Advanced Recordset.
Your help and detailed answer will be greatly appreciated!
Thanks!
Comment