Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Second Filter on Search results

Guest
Dec 31, 2009 Dec 31, 2009

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

TOPICS
Server side applications
410
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 31, 2009 Dec 31, 2009

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

...
Translate
LEGEND ,
Dec 31, 2009 Dec 31, 2009

SELECT FROM inventory

WHERE pressure > 200

AND status = 'new'

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 31, 2009 Dec 31, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2009 Dec 31, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 04, 2010 Jan 04, 2010
LATEST

Thanks for the info David.  I will be using your method to have a more advanced search feature!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines