I need a php script that will use the values of the form's checkboxes as the MySQL query to retrieve data. I'm thinking I'll need to use WHERE along with the OR operator in the query.
My PHP and MySql level is beginner.
<form id="form1" name="form1" method="post" action="">
<p>
<h3>story</h3>
<label><input type="checkbox" name="story" value="1" id="story_1" />one story</label>
<label><input type="checkbox" name="story" value="2" id="story_2" />two story</label>
</p>
<p>
<h3>bedrooms</h3>
<label><input type="checkbox" name="bedroom" value="2" id="bed_2" />two beds</label>
<label><input type="checkbox" name="bedroom" value="3" id="bed_3" />three beds</label>
<label><input type="checkbox" name="bedroom" value="4" id="bed_4" />four beds</label>
</p>
<p>
<h3>baths</h3>
<label><input type="checkbox" name="bath" value="1" id="bath_1" />one bath</label>
<label><input type="checkbox" name="bath" value="2" id="bath_2" />two baths</label>
<label><input type="checkbox" name="bath" value="3" id="bath_3" />three baths</label>
</p>
<input type="submit" name="search" value="search" />
</form>
My query so far
SELECT * FROM homes WHERE story='1' OR story='2' OR bed='3' OR baths='3'
So if no checkboxes are checked no WHERE clause will be added at all and it will default to retrieve all records.
name="story[]". Use arrays or radio buttons.