title: Using checkboxes to filter records PHP MySQL
body: <p>I am a PHP and MySQL novice, so please keep your answers simple!!!</p>
  
  <p>I have a database that lists a bunch of retirement communities and the services they offer. I have a series of fields using a boolean (tinyint) and if they offer the service, they get a 1. If they don't they get a 0.</p>
  
  <p>I have it display fine, but now I am trying to filter the list using checkboxes. I am also searching by City and State (which work) but once I add my code for the checkboxes, it fails. It just shows all the records no matter what. Here is what I have:</p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;form action="" method="post"&gt;
  &lt;fieldset&gt;&lt;legend&gt;Filter&lt;/legend&gt;
      &lt;p&gt;&lt;label&gt;City:&amp;nbsp;&lt;/label&gt;&lt;input type="text" name="by_city" /&gt;&lt;/p&gt;
      &lt;p&gt;&lt;label&gt;State:&amp;nbsp;&lt;/label&gt;&lt;input type="text" name="by_state" /&gt;&lt;/p&gt;
      &lt;p&gt;
      &lt;input type="checkbox" name="IndependentLiving" value="1" /&gt;    Independent Living&lt;br&gt;
      &lt;input type="checkbox" name="AssistedLiving" value="1" /&gt; Assisted Living&lt;br&gt;
      &lt;input type="checkbox" name="SkilledNursing" value="1" /&gt; Skilled Nursing&lt;br&gt;
      &lt;input type="checkbox" name="MemoryCare" value="1" /&gt; Memory Care&lt;br&gt;
      &lt;input type="checkbox" name="ContinuingCareCommunity" value="1" /&gt; Continuing Care Community&lt;br&gt;
      &lt;input type="checkbox" name="Respite" value="1" /&gt;  Short-term/Respite&lt;br&gt;
      &lt;/p&gt;
      &lt;p&gt;&lt;input class="button" type="submit" name="submit" value="Search" /&gt;&lt;/p&gt;
  &lt;/fieldset&gt;     
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>$by_city = $_POST['by_city'];
  $by_state = $_POST['by_state'];
  $IndependentLiving = $_POST['IndependentLiving'];
  $AssistedLiving = $_POST['AssistedLiving'];
  $SkilledNursing = $_POST['SkilledNursing'];
  $MemoryCare = $_POST['MemoryCare'];
  $ContinuingCareCommunity = $_POST['ContinuingCareCommunity'];
  $Respite = $_POST['Respite'];
  
  
  
  mysql_select_db('CommunityList');
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $query = "SELECT * FROM Communities WHERE (City='$by_city') OR (State='$by_state') OR (IndependentLiving='$IndependentLiving') OR (AssistedLiving='$AssistedLiving') OR (SkilledNursing='$SkilledNursing') OR (MemoryCare='$MemoryCare') OR (ContinuingCareCommunity='$ContinuingCareCommunity') OR (Respite='$Respite')";
  }
  else {
  $query = "SELECT * FROM Communities";
  }
  $result = mysql_query($query);
  </code></pre>