Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Search Results Help Needed

Status
Not open for further replies.

Stevesph

Technical User
Oct 10, 2008
2
ES
Hi
I work in branch of the travel industry. I have made a PHP MySQL database and using Dreamweaver have prepared the search page that includes 3 dynamic dropdown menus. The first is Property Type, the second Location and the third is Bodies. There is a recordset for each menu :


Recordset (RSlocation)
Recordset (RSproperty)
Recordset (RSbodies)

and the corresponding Dynamic List/Menus:

Dynamic List/Menu (list_location)
Dynamic List/Menu (list_property)
Dynamic List/Menu (list_bodies)

I have filtered the SQL to return distinct values so that they look like this

SELECT DISTINCT apartments_test_xps.Location
FROM apartments_test_xps

SELECT DISTINCT apartments_test_xps.property
FROM apartments_test_xps

SELECT DISTINCT apartments_test_xps.Bodies
FROM apartments_test_xps

So far so good. The SQL for the results page look like this:

SELECT *
FROM apartments_test_xps
WHERE apartments_test_xps.Location = list_location AND apartments_test_xps.property = list_property AND apartments_test_xps.bodies >= list_bodies

with these variables

list_location
Name:list_location
Type:Text
Default Value: Balcon de Los Gigantes
Run_time Value: $_GET['list_location']

list_property
Name:list_property
Type:Text
Default Value: Apartment
Run_time Value: $_GET['list_property]

list_bodies
Name:list_bodies
Type:Numeric
Default Value: 4
Run_time Value: $_GET['list_bodies']

Using the above procedures produces just the results I am looking for with one exception. I cannot figure out how to filter the Location menu to also include an ANY or ALL location variable without messing up the results. I tried to insert a static value using the name ANY with the wildcard * value, but this returns no results at all.
I suspect the SQL on the results page needs further tweeking but I have to admit that I am really struggling with this.
Any help would be great.
Thank you
Steve
 
Try something like
Code:
WHERE (apartments_test_xps.Location = list_location [b]or list_location = "ALL")[/b]
AND ...


Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Many thanks for your response. Will give your suggestion my full attention.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top