I have a database that has a column named "SubCategory". Within the subcategory column there are 3 fields (Banks, Lenders, Realtors)I'm passing an URL parameter and what I'm trying to do is select certain fields only if the SubCategory ='Realtors' and the BankLocation='URL Parameter value"
So here is the query I have:
SELECT username, company, categories, profile, email
WHERE freelancers_programmers.SubCategory = 'Realtor' AND BankLocation = 'colname'
The 'colname' is a variable whose name is 'colname' has a default value of 1, and a runtime value of $_GET['BankLocation'] and it carries of the value of the selected state when passed
The problem I'm having is that the query isn't filtering the SubCategory='Realtors'....the search results come back with not only 'Realtors', but 'Banks' and 'Lenders' as well. I only want 'Realtors' whose 'BankLocation' is passed in the search.
If you need to see a live example visithttp://www.searchbanks.com//realtors.php
and use the "
Quick Search by States" section...Florida has the 'Realtor' and 'Alabama' has a lender but if you choose 'Alabama' the lender comes back in the search result....that shouldn't happen because I want to limit the search results on this page to 'Realtors' only for the selected state.
First of all, I think we should clarify some vocabulary... From your query, it seems to me that :
"freelancers_programmers" is a table (do you have only one ?),
within which you have a column (or field) "SubCategory",
which may have values among 'Banks', 'Lenders', 'Realtors'.
Is that so ? Because if it is, I don't see any error in your query.
However, why do you have "freelancers_programmers.SubCategory" and "BankLocation". Both columns belong to the "freelancers_programmers" table, isn't it ? If it is, you could just put "SubCategory". This is just a detail, but I try to understand why it would not work properly.
Could you please be more precise about your schema ? Don't you have to use other tables ?
PS : you put 'Realtors' with 's' everywhere except in your query where you put 'Realtor'... but even if it were an error, then you would have no result at all, not all results... really strange. Are you sure you did put "AND" in your code and not "OR" ? Then it would make sense.