I am having a simple problem whereby i am filtering data to a browsers requirement to display results from a mysql database. The problem is that when i use the "and" statement and do not enter any data in certain fields i will receive the "no results displayed" unless i can specifically choose criteria from all fields. I am tearing my hear out over something that is meant to be simple but do not know what.
I will paste the sql query code below. What i am trying to do is for example; search for a property in the database where county is like $county and style is like $style and then filters the results accordingly. If i use the 'or' command i know i will retrieve the results from one query or the other. What i am trying to do is be specific but if for example the user places a search criteria in 'county' but not in the style i would like it to filter for criteria matches for county and then set the style to not match as nothing is entered. I have also placed value=0 in the style field so if the field is not chosen it wont need to match any thing. Every time i do this it still results in no results found. I can paste all of my code if it is required but i feel i have a problem in how i am calling these features up.
Can somebody help
Kind Regards
php-learner
My Code
$query = "select * from listings where county like '$county' and style like '$style' order by price DESC limit $offset, $limit";