title: I need help creating a php script that would filter and display the results from mysql database using an html form
body: <p>I'm fairly inexperienced when it comes to php and sql queries, so please forgive my terminology if it's off. I have an html webpage with a form that I want to use to filter my mysql databases php results. I'm hoping that whoever can answer this can either create the code for me, or give me the basics with a detailed explanation so I can create the rest myself. The form I am using filters using all or some of the following:</p>
  
  <p>checkboxes
  text fields
  drop down options</p>
  
  <p>Without further ado, here is my HTML code:
      
      </p>
  
  <pre><code>&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Anime Database Search&lt;/title&gt;
    &lt;link href="CSS Files/vignette.css" rel="stylesheet" type="text/css"&gt;
    &lt;link href="CSS Files/body.css" rel="stylesheet" type="text/css"&gt;
    &lt;link href="CSS Files/base.css" rel="stylesheet" type="text/css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div id="banner"&gt;
      &lt;p class="vignette"&gt;&lt;img id="banner" src="Images/Banners/SAO Banner.jpg" alt="Sword Art Online Banner" height="197px" width="100%"/&gt;&lt;/p&gt;
    &lt;/div&gt; &lt;!-- end banner --&gt;
  
    &lt;header&gt;
      &lt;nav id="nav"&gt;
         &lt;ul&gt;
           &lt;li&gt;&lt;a href="index.html"&gt;Anime Search&lt;/a&gt;&lt;/li&gt;
           &lt;li&gt;&lt;a href="anime_movies.html"&gt;Anime Movie Search&lt;/a&gt;&lt;/li&gt;
           &lt;li&gt;&lt;a href="movies.html"&gt;Movie Search&lt;/a&gt;&lt;/li&gt;
           &lt;li&gt;&lt;a href="ondemand.html"&gt;On Demand Series Search&lt;/a&gt;&lt;/li&gt;
         &lt;/ul&gt;
      &lt;/nav&gt;
      &lt;hgroup&gt;
         &lt;h2&gt;Anime Database Search&lt;/h2&gt;
      &lt;/hgroup&gt;
    &lt;/header&gt;
  
    &lt;form id="search" action="anime.php" method="GET"&gt;
  
    &lt;b&gt;Title:&lt;/b&gt;
    &lt;br&gt;
    &lt;input type="text" name="search_box" value="" /&gt;
  
    &lt;br&gt;
    &lt;br&gt;
  
    &lt;b&gt;Release Date:&lt;/b&gt;
      &lt;br&gt;
    &lt;input type="us-date1" name="mindate"&gt; to &lt;input type="us-date2" name="maxdate"&gt;
  
    &lt;br&gt;
    &lt;br&gt;
  
    &lt;b&gt;Licensing Type:&lt;/b&gt;
    &lt;br&gt;
      &lt;select name="license"&gt;
        &lt;option selected value="title"&gt;Licensing&lt;/option&gt;
        &lt;option value="dubbed"&gt;Dubbed Titles Only&lt;/option&gt;
        &lt;option value="subbed"&gt;Subbed Titles Only&lt;/option&gt;
      &lt;/select&gt; &lt;!-- end license --&gt;
  
    &lt;br&gt;
    &lt;br&gt;
  
      &lt;b&gt;Genres:&lt;/b&gt; &lt;div id="genres"&gt;
          &lt;div id="left"&gt;
            &lt;input type="checkbox" name="genre[]" value="action"&gt;Action&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="adventure"&gt;Adventure&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="comedy"&gt;Comedy&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="drama"&gt;Drama&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="fantasy"&gt;Fantasy&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="horror"&gt;Horror&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="magic"&gt;Magic&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="mecha"&gt;Mecha&lt;/input&gt;&lt;br&gt;
          &lt;/div&gt; &lt;!-- end left --&gt;
          &lt;div id="right"&gt;
            &lt;input type="checkbox" name="genre[]" value="mystery"&gt;Mystery&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="psychological"&gt;Psychological&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="romance"&gt;Romance&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="science fiction"&gt;Science Fiction&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="slice of life"&gt;Slice of Life&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="supernatural"&gt;Supernatural&lt;/input&gt;&lt;br&gt;
            &lt;input type="checkbox" name="genre[]" value="thriller"&gt;Thriller&lt;/input&gt;&lt;br&gt;
          &lt;/div&gt; &lt;!-- end right --&gt;
      &lt;/div&gt; &lt;!-- end genres --&gt;
  
    &lt;br&gt;
    &lt;br&gt;
  
      &lt;div id="Sort_By"&gt;
      &lt;b&gt;Sort By:&lt;/b&gt;
      &lt;br&gt;
      &lt;select name="Sort" required&gt;
        &lt;option selected value="rating"&gt;Rating&lt;/option&gt;
        &lt;option value="alphabetical"&gt;Alphabetical&lt;/option&gt;
        &lt;option value="released"&gt;Release Date&lt;/option&gt;
      &lt;/select&gt; &lt;!-- end Sort --&gt;
      &lt;/div&gt; &lt;!-- end Sort_by --&gt;
  
    &lt;br&gt;
  
      &lt;div id="search_buttons"&gt;
        &lt;input type="submit" name="Search" value="Search"&gt;
        &lt;input type="reset" value="Reset"&gt;
      &lt;/div&gt; &lt;!-- end search_button --&gt;
  
    &lt;/form&gt; &lt;!-- end search --&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is my PHP code:
      
  
  <pre><code>// Include DB Connection File
  include "db_connection.php";
  ?&gt;
  
  &lt;!-- Stylesheet for Table --&gt;
  &lt;style&gt;
    &lt;?php
      include "CSS Files/php_results.css"
    ?&gt;
  &lt;/style&gt;
  
  &lt;style&gt;
    &lt;?php
      include "CSS Files/vignette.css"
    ?&gt;
  &lt;/style&gt;
  
  &lt;style&gt;
    &lt;?php
      include "CSS Files/base.css"
    ?&gt;
  &lt;/style&gt;
  
  &lt;?php
  
  $query = "SELECT * FROM anime_combined ";
  
  $fetch = mysql_query($query) or die($dberror1);
  ?&gt;
  
  &lt;head&gt;
    &lt;title&gt;Results&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;header&gt;
  &lt;p class="vignette"&gt;&lt;img id="banner" src="/Images/Banners/SAO Banner.jpg" alt="Sword Art Online Banner" height="24.5%" width="100%"/&gt;&lt;/p&gt;
    &lt;nav id="nav"&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href="index.html"&gt;Anime Search&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="anime_movies.html"&gt;Anime Movie Search&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="movies.html"&gt;Movie Search&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="ondemand.html"&gt;On Demand Series Search&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/header&gt;
  
  &lt;div id="table"&gt;
  &lt;table cellpadding="5" border="1"&gt;
      &lt;tr&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Title&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Genre&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Season&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Episodes&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Released&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Media Type&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Sub/Dub&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Status&lt;/strong&gt;&lt;/td&gt;
        &lt;td class="results"&gt;&lt;strong&gt;Rating&lt;/strong&gt;&lt;br&gt;&lt;p&gt;(5 stars)&lt;/p&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php
    while($row = mysql_fetch_assoc($fetch)){ ?&gt;
        &lt;tr&gt;
          &lt;td id="title"&gt;&lt;?php echo $row['Title']; ?&gt;&lt;/td&gt;
          &lt;td id="genre"&gt;&lt;?php echo nl2br($row['Genre']); ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Season']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Episodes']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Released']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Type']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Licensing']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Status']; ?&gt;&lt;/td&gt;
          &lt;td class="results"&gt;&lt;?php echo $row['Rating']; ?&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;?php
    } //end $fetch
    ?&gt;
  &lt;/table&gt;
  &lt;/div&gt; &lt;!-- end table --&gt;
  &lt;button onclick="history.go(-1);"&gt;Return To Search&lt;/button&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I used a view that queried my two tables together in mysql if that helps to know. One table has just the title and genres while the other table has the rest of the information.</p>
  
  <p>Please help. I've asked this question a few times and am still so confused with how to do it.</p>