0

Hi i had a mysql database ( coading in php ) in my real estate web site. It had 4 columns.

1. for ( ie, buy or rent )
2. district
3. Type ( villa,house,.....)
5. price ( 1 lakh, 2lakh, 3 lakh ...)

I need to add a searh in my home page. Using any of the colomns in above. I already did it with

all these columns like ("select * from database where for='$for' and district='$district' and type='$type' and price='price'"). Now I need to do custom search like district= All , type=All and price=Any.....

Please help me.....
Thanks in Advance
Rajeesh

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by verruckt24
0

select * from database would work just fine since you want all the records without satisfying any condition :)
Btw, 'for' and 'type' are mysql reserve keywords and requires ` to be wrapped around it.
like, `for`, `type`.

0

@naveen : Good point there about the keywords, but I guess he has framed his question wrong.

@OP : Would you be able to define a custom search in more detail or reframe your question, cause "district = all, typ = all and price = all" is not a search at all.

0

Ok. I meant that it is not mandatory to select all the inputs. for example
User can search for "rent" by keeping district "all" type "all" and price "any"...
another one . User can search for "rent" and district "abc" and type"all" and also price "any"

One more search for "rent" by keeping district "all" type "all" and price "2lakh"...

please help me...
thanks for supports...

0

If the user has selected "All" or "any", exclude it from your query condition list. :-/
For example, If he search for "rent" and keeps district as "all" and price as "2 lakh", your query should look something like,

select * from table where `for`='rent' and price='2 lakhs'

I still don't understand how is this advance search. :)

0

For a custom search, what you can do is, have multiple queries written each for a different search that can be done on your database and select the appropiate one to fire, dynamically, based on the search parameters entered by your user.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.