title: Retrieve data with a form using WHERE for multiple checkboxes
body: <p>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. </p>
  
  <p>My PHP and MySql level is beginner. </p>
  
  <pre><code>&lt;form id="form1" name="form1" method="post" action=""&gt;
  
      &lt;p&gt;
          &lt;h3&gt;story&lt;/h3&gt;
          &lt;label&gt;&lt;input type="checkbox" name="story" value="1" id="story_1" /&gt;one story&lt;/label&gt;
          &lt;label&gt;&lt;input type="checkbox" name="story" value="2" id="story_2" /&gt;two story&lt;/label&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;h3&gt;bedrooms&lt;/h3&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bedroom" value="2" id="bed_2" /&gt;two beds&lt;/label&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bedroom" value="3" id="bed_3" /&gt;three beds&lt;/label&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bedroom" value="4" id="bed_4" /&gt;four beds&lt;/label&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;h3&gt;baths&lt;/h3&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bath" value="1" id="bath_1" /&gt;one bath&lt;/label&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bath" value="2" id="bath_2" /&gt;two baths&lt;/label&gt;
          &lt;label&gt;&lt;input type="checkbox" name="bath" value="3" id="bath_3" /&gt;three baths&lt;/label&gt;
      &lt;/p&gt;
  
      &lt;input type="submit" name="search" value="search" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>My query so far</p>
  
  <pre><code>SELECT * FROM homes WHERE story='1' OR story='2' OR bed='3' OR baths='3'
  </code></pre>
  
  <p>So if no checkboxes are checked no WHERE clause will be added at all and it will default to retrieve all records.</p>