Can the OR keyword be used for same field in a mysql table?

I’m trying to create a search form where members of a site can search other members whose user information is stored in a mysql database. One of the search parameters is gender which searches for records from a column in the database called gender where members can either have the value “man” or “woman”. The user can choose between 3 options from a pull down menu named gender (man, woman, both). Then I’m thinking about using a select query to search the database upon submission of the form, which goes something like this:
[php]

$sql= SELECT* FROM members WHERE gender =’{$_POST[‘gender’]}’ ;

[/php]
Now I can easily assign the value “man” for the option man in the pull down menu and "woman for the option woman, to match their corresponding names in the database. The problem lies with the “both” option which has to be either man or woman. I’m thinking about assigning it the value “man OR woman” so that when the form is submitted, the query would read: SELECT*FROM members WHERE gender =’{$_POST[man OR woman’]};
I just don’t know if this would be a right usage of the OR keyword and if such a query would work. Before trying it out, I’d like to know if this makes any sense and if not, what’s an alternative way to work around this?

Well I forgot to mention that there are other search parameters besides gender. Take for example lets say I had to search for gender AND interest. That compels me to specify the WHERE clause for both columns right? With that in mind, how would I handle this?

[php]$sql= SELECT* FROM members WHERE gender =’{$_POST[‘gender’]}’ OR interest = ‘{$_POST[‘interest’]}’;[/php]

Personally, I think that in your search form for gender, if they want to select man OR woman, they shouldn’t need to choose that in the form. It should be default.

Sponsor our Newsletter | Privacy Policy | Terms of Service