title: Advanced search using textboxes and checkboxes
body: <p>I'm having trouble getting my "Advanced Search" functionality of my website working.
  Essentially, its an advanced search for musicians (city, name members, zip by text box and genre by checkboxes). Here is code on the "Advanced Search" php page...</p>
  
  <pre><code>&lt;form method="post" action="advsearchresults.php"&gt;
  &lt;div class="control-group"&gt;
      &lt;div class="controls span4"&gt;
      &lt;label&gt;City&lt;/label&gt;
          &lt;input type="text" name="advCity" placeholder="Ex: San Marcos..." /&gt;
      &lt;label&gt;Zip Code&lt;/label&gt;
      &lt;input type="text" name="advZip" placeholder="Ex: 78666..." /&gt;
      &lt;label&gt;Band Name&lt;/label&gt;
          &lt;input type="text" name="advBand" placeholder="Ex: Catchy Band Name..." /&gt;
      &lt;label&gt;Band Member Name&lt;/label&gt;
          &lt;input type="text" name="advMember" placeholder="Ex: Steve Stevenson..." /&gt;
  &lt;/div&gt;
  &lt;div class="controls span2"&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;
      &lt;label class="checkbox"&gt;
          &lt;input type="checkbox" name="check_list[]" value="Blues"&gt; Blues
      &lt;/label&gt;
      &lt;label class="checkbox"&gt;
          &lt;input type="checkbox" name="check_list[]" value="Classical"&gt; Classical
      &lt;/label&gt;
      &lt;label class="checkbox"&gt;
          &lt;input type="checkbox" name="check_list[]" value="Comedy"&gt; Comedy
      &lt;/label&gt;
      &lt;label class="checkbox"&gt;
      &lt;input type="checkbox" name="check_list[]" value="Country"&gt; Country
      &lt;/label&gt;
      ...
      ...
      &lt;/div&gt;
      &lt;div class="span12"&gt;
          &lt;center&gt;
          &lt;input type="submit" class="btn btn-info" value=" Advanced Search "&gt;
      &lt;/div&gt;
      ...
  </code></pre>
  
  <p>And here is the "Advanced Search Results" page...</p>
  
  <pre><code>...
  &lt;?php
  $advCity = $_POST['advCity'];
  $advZip = $_POST['advZip'];
  $advBand = $_POST['advBand'];
  $advMember = $_POST['advMember'];
  $check = $_POST['check_list'];
  ?&gt;
  ...
  
  &lt;?php
  if(isset($_POST['check_list']) &amp;&amp; is_array($_POST['check_list'])){
      foreach($_POST['check_list'] as $check) {
          $genreQuery = "SELECT profile.PROFILE_GENRE, profile.PROFILE_BANDNAME
          FROM profile INNER JOIN band ON profile.PROFILE_PROFILEID = band.BAND_PROFILEID
          INNER JOIN bandmember ON band.BAND_BANDID = bandmember.BANDMEMBER_BANDID
          WHERE band.BAND_CITY = '$advCity' OR profile.PROFILE_GENRE = '$check' 
          OR band.BAND_ZIP = '$advZip' OR profile.PROFILE_BANDNAME = '$advBand' 
          OR bandmember.BANDMEMBER_NAME = '$advMember'";              
      $result = mysql_query($genreQuery) OR die(mysql_error());
      $num=mysql_numrows($result);
      mysql_close();
  if ($num &gt; 0){
      ?&gt;
      &lt;table class="table table-hover span8" method="post" action="bandpage.php"&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Genre&lt;/th&gt;
          &lt;th&gt;Band Name&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;?php
          $i = 0;
          while ($i &lt; $num) {
              $GENRE = mysql_result($result,$i,"profile.PROFILE_GENRE");
              $BANDNAME = mysql_result($result,$i,"profile.PROFILE_BANDNAME");
      ?&gt;
      &lt;tbody&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;?php echo $GENRE; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href="bandpage.php" name="band"&gt;&lt;?php echo $BANDNAME; ?&gt;
      &lt;/a&gt;&lt;/td&gt;&lt;/tr&lt;/tbody&gt;
      &lt;?php
          $i++;               
          }
          }
  else {
  ?&gt;  
      &lt;table class="table span8"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
          &lt;th&gt;No musicians available for the city: &lt;?php echo $advCity ?&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;/table&gt;
  &lt;?php
      }
      }
      }
  ?&gt;
  </code></pre>
  
  <p>The search results don't show up at all, rather random table data is shown. Any help is much appreciated!</p>
  
  <h3>Formatted SQL:</h3>
  
  <pre><code>SELECT
      profile.PROFILE_GENRE,
      profile.PROFILE_BANDNAME
  FROM
      profile
      INNER JOIN band       ON profile.PROFILE_PROFILEID = band.BAND_PROFILEID
      INNER JOIN bandmember ON band.BAND_BANDID          = bandmember.BANDMEMBER_BANDID
  WHERE
      band.BAND_CITY             = '$advCity' OR
      profile.PROFILE_GENRE      = '$check' OR
      band.BAND_ZIP              = '$advZip' OR
      profile.PROFILE_BANDNAME   = '$advBand' OR
      bandmember.BANDMEMBER_NAME = '$advMember'
  </code></pre>