Ok I am very new to the php mysql world so please bare with me.
I have set up a database for an apartment complex with a table containing the following:
create table apartments (apt_num int not null, available varchar(5) not null, beds int not null, baths int not null, pets varchar(5) not null, lease_start varchar(25), lease_end VARCHAR(25), descr varchar(25) not null, primary key (apt_num));
I am now creating a form that contains check boxes for users to select what they want to search for, and return the correct results... for example:
<input type=”checkbox” checked="checked" name=”bdrm[]” value=”Any″>
<input type=”checkbox” name=”bdrm[]” value=”1″>
<input type=”checkbox” name=”bdrm[]” value=”2″>
<input type=”checkbox” name=”bdrm[]” value=”3″>
<input type=”checkbox” checked="checked" name=”btrm[]” value=”Any″>
<input type=”checkbox” name=”btrm[]” value=”1″>
<input type=”checkbox” name=”btrm[]” value=”2″>
<input type=”checkbox” checked="checked" name=”pets[]” value=”Any″>
<input type=”checkbox” name=”pets[]” value=”Yes″>
<input type=”checkbox” name=”pets[]” value=”No″>
my question is: how would i use php to insert it into a query such as this:
SELECT * FROM apartments WHERE beds='bdrmChecked' AND baths='btrmChecked' AND pets='petsChecked';
Another problem is that if a user checked "Any" it wouldn't return any results because the value "Any" wouldn't exist in the table...
Any help is appreciated!