Copy link to clipboard
Copied
I have a php page that loadsproducts on the page. Across the top are links so that the user can filter the results. The links are seperated into columns. As the user click an option in each column, I want the results to keep narrowing down. Is it possible to get filtered products and then further filter that with 2 simpler sql statments or do I have to use one big one?
Example:
Use this: SELECT * FROM INVENTORY WHERE Pressure > 200
and this (From Results of previous statement) SELECT * WHERE Status = New
I've attached a pic of the lay out so hopefully you can get an idea of what I am trying to accomplish
PHE Admin wrote:
I want to now query the results I have already retrived without going back to the database. something like: secondresults = $result->query("Select * WHERE status = 'new')
You can't. PHP is a server-side language. It runs on the server, and sends the results back to the browser.
there are tons of combinations that if I make them One sql statment, it will result in a huge if else if... statment with all the different combinations.
See the following article for details of how to simpli
...Copy link to clipboard
Copied
SELECT FROM inventory
WHERE pressure > 200
AND status = 'new'
Copy link to clipboard
Copied
I understand the SQL part of it. I don't think I made my self clear.
I queried my db:
$result =$dblink->query("SELECT * FROM Inventory WHERE Pressure > 200);
Those results are displayed on the website. The user has multiple options to filter further. (By horsepower, make, model, etc...) I want to now query the results I have already retrived without going back to the database.
something like: secondresults = $result->query("Select * WHERE status = 'new')
If you look at the pic, the user can select multiple options. by the time they get to the last column, there are tons of combinations that if I make them One sql statment, it will result in a huge if else if... statment with all the different combinations.
Copy link to clipboard
Copied
PHE Admin wrote:
I want to now query the results I have already retrived without going back to the database. something like: secondresults = $result->query("Select * WHERE status = 'new')
You can't. PHP is a server-side language. It runs on the server, and sends the results back to the browser.
there are tons of combinations that if I make them One sql statment, it will result in a huge if else if... statment with all the different combinations.
See the following article for details of how to simplify a query that has a lot of different options: http://cookbooks.adobe.com/post_Create_search_query_with_optional_fields-16245.html.
The only way to allow the user to drill down in the results already displayed is to use an Ajax remote call to the database, but it still requires another database call. If you don't want to go back to the database, you might be able to do it by loading all the results into a JavaScript array and manipulating that in the browser, but it's still going to be a major undertaking in terms of coding - and it won't work if JavaScript is disabled.
Copy link to clipboard
Copied
Thanks for the info David. I will be using your method to have a more advanced search feature!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now