title: Search Form with One or More (Multiple) Parameters
body: <p>I've gotten the basics down, where I've created two files, the search form where a user inputs search parameters, and the results file that cranks out inputted items. For the sake of simplicity, we'll designate the search form file as search.php and the results page as results.php.</p>
  <p>search.php</p>
  <pre><code>&lt;?php
      
  if (!empty($_POST['id']) &amp;&amp; isset($_POST['id'])) {
      header(&quot;Location: ?m=search.results&amp;id=&quot;.$_POST['id'].&quot;&quot;);
  } elseif (!empty($_POST['major']) &amp;&amp; isset($_POST['major'])) {
      header(&quot;Location: ?m=search.results&amp;major=&quot;.$_POST['major'].&quot;&quot;);
  } elseif (!empty($_POST['college']) &amp;&amp; isset($_POST['major'])) {
      header(&quot;Location: ?m=search.results&amp;college=&quot;.$_POST['college'].&quot;&quot;);
  } elseif (!empty($_POST['name']) &amp;&amp; isset($_POST['name'])) {
      header(&quot;Location: ?m=search.results&amp;name=&quot;.$_POST['name'].&quot;&quot;);
  } elseif (!empty($_POST['id']) &amp;&amp; !empty($_POST['college']) &amp;&amp; !empty($_POST['major'])
                              &amp;&amp; isset($_POST['submit']) &amp;&amp; !empty($_POST['name'])) {
      echo &quot;&lt;div class='alert alert-danger'&gt;No students found. Please try different parameters.&lt;/div&gt;&quot;;
  }
  
  ?&gt;
  
  
  &lt;h4&gt;Search&lt;/h4&gt;
  
  &lt;form method=&quot;POST&quot;&gt;
      &lt;table width=&quot;100%&quot;&gt;
  
  &lt;tr&gt;&lt;td&gt;ID:&lt;/td&gt;&lt;td&gt; &lt;input type=&quot;text&quot; name=&quot;id&quot; class=&quot;form-control&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt;&lt;td&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;form-control&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt;Major:&lt;/td&gt;&lt;td&gt;&lt;select name=&quot;major&quot; class=&quot;form-control&quot;&gt;&lt;option&gt;&lt;/option&gt;&lt;?php echo majorSelect(); ?&gt;&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
  
      &lt;tr&gt;&lt;td&gt;College:&lt;/td&gt;&lt;td&gt;&lt;select name=&quot;college&quot; class=&quot;form-control&quot;&gt;&lt;option&gt;&lt;/option&gt;&lt;?php echo collegeSelect(); ?&gt;&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search&quot; class=&quot;btn btn-lrg btn-primary&quot; style=&quot;margin-top:10px;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
  
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  <p>results.php</p>
  <pre><code>&lt;!-- Begin Search Parameters --&gt;
  
  &lt;?php
  
  if (isset($_GET['id'])) {
      $students = $db-&gt;query(&quot;SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.uid = '&quot;.$_GET['id'].&quot;'&quot;);
      
      while ($student = $students-&gt;fetch()) {
          echo '
              &lt;tr&gt;
                  &lt;td&gt;'.$student['uid'].'&lt;/td&gt;
                  &lt;td&gt;'.$student['name'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['major'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['college'].'&lt;/td&gt;
                  &lt;td&gt;&lt;a href=&quot;?m=profile&amp;id='.$student['id'].'&quot; style=&quot;display:block&quot;&gt;View&lt;/a&gt;&lt;/td&gt;
                  
              &lt;/tr&gt;';
      }
  } elseif (isset($_GET['major'])) {
      $students = $db-&gt;query(&quot;SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.major = '&quot;.$_GET['major'].&quot;'&quot;);
          
      while ($student = $students-&gt;fetch()) {
          echo '
              &lt;tr&gt;
                  &lt;td&gt;'.$student['uid'].'&lt;/td&gt;
                  &lt;td&gt;'.$student['name'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['major'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['college'].'&lt;/td&gt;
  
                  &lt;td&gt;&lt;a href=&quot;?m=profile&amp;id='.$student['id'].'&quot; style=&quot;display:block&quot;&gt;View&lt;/a&gt;&lt;/td&gt;
                  
              &lt;/tr&gt;';
      }
  } elseif (isset($_GET['college'])) {
      $students = $db-&gt;query(&quot;SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.college = '&quot;.$_GET['college'].&quot;'&quot;);
          
      while ($student = $students-&gt;fetch()) {
          echo '
              &lt;tr&gt;
                  &lt;td&gt;'.$student['uid'].'&lt;/td&gt;
                  &lt;td&gt;'.$student['name'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['major'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['college'].'&lt;/td&gt;
                  &lt;td&gt;&lt;a href=&quot;?m=profile&amp;id='.$student['id'].'&quot; style=&quot;display:block&quot;&gt;View&lt;/a&gt;&lt;/td&gt;
                  
              &lt;/tr&gt;';
      }
  } elseif (isset($_GET['name'])) {
      $name = $_GET['name'];
          
      $students = $db-&gt;query(&quot;SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND b.name LIKE '%&quot;. $name . &quot;%'&quot;);
          
      while ($student = $students-&gt;fetch()) {
          echo '
              &lt;tr&gt;
                  &lt;td&gt;'.$student['uid'].'&lt;/td&gt;
                  &lt;td&gt;'.$student['name'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['major'].'&lt;/td&gt;
                      &lt;td&gt;'.$student['college'].'&lt;/td&gt;
                  &lt;td&gt;&lt;a href=&quot;?m=profile&amp;id='.$student['id'].'&quot; style=&quot;display:block&quot;&gt;View&lt;/a&gt;&lt;/td&gt;
                  
              &lt;/tr&gt;';
      }
  }    
  </code></pre>
  <p>So, essentially I would like to rewrite the above whereas a user can input one or more parameters, and the desired result is returned (e.g. both name and college - &amp;name=x&amp;college=y OR all items if need be).</p>