I'm having some major problems with my logic on my search function. For example,
Here is the form if there is text after a colon thats text from a drop down list.
Search For A Specific House
Number of Bedrooms: any 1 2 3 4 5
Number Of Bathrooms: any 1 2 3 4 5
Square Footage: Min: any 400 500 600 700 800 900 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 Max: any 400 500 600 700 800 900 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500
Garage: any yes no
Pool: any yes no
Style: modern spanish victorian colonial bungalow ranchstyle
they fill in all or any of this form above and click submit.
so now here is my query problems.............
$result = mysql_query("SELECT* FROM house WHERE city='$city' AND zipcode='$zip' AND garage='$garage' ");
so this was just my first test with just zip,city,and garage. The first problem i'm noticing is lets say zip,city were matches in the database but they left the garage part blank therefore that variable is null or blank or something and when it looks for all these together because garage was left blank it displays zero results when i would have liked to show at least the things that matched city and zip. So, I figured what if instead i "OR" everything. The problem there is it shows way too much example would be they put in city as san jose and filled in other stuff like garage etc... this would return other cities houses because other parts match and it is or'd. How do I create a decent search function it does not need to be to technical at all just sort of decent at returning results that match. Here is the columns in my phpadmin tables. any ideas will be very helpfull!
address |city |zipcode |sqrfootage |bed |bath |garage| pool |fireplace| style | realtor| askingprice |picture
2388 cherry ave san jose 95125 1000 2 1 no no no modern johny five 650,000 http://www.southbaybeagles.com/house/h1.jpg
1156 lincoln san jose 95050 900 4 2 yes no no modern 700,000 http://www.southbaybeagles.com/house/h2.jpg
4567 harry wy santa clara 95056 1200 3 2 yes no yes spanish johny 750,000 http://www.southbaybeagles.com/house/h3.jpg
2323 potter ln cambell 94123 800 2 1 no no no ranch style 500,000 http://www.southbaybeagles.com/house/h4.jpg
23456 fread wy santa clara 95123 1300 3 2 yes no no spanish harry 700,500 http://www.southbaybeagles.com/house/h5.jpg