title: Create a filter button SQL query
body: <p>I'm creating a filter button on my SQL query. I have a form where a user can insert a date and then a button after it. Whenever a user clicks this button it only searches for that date in the table. I've created all this but it's not working. </p>
  
  <p>It's not giving me an error or anything..</p>
  
  <pre><code>$mysqli = mysqli_connect("localhost", "root", "", "urenregistratie");
  </code></pre>
  
  <p>The button doesn't do anything. This is what I have:</p>
  
  <pre><code>&lt;body&gt;
     &lt;div class="form"&gt;
     &lt;p&gt;
        &lt;a href="dashboard.php"&gt;Dashboard&lt;/a&gt; | &lt;a href="view.php"&gt;Projecten inzien&lt;/a&gt; | &lt;a href="logout.php"&gt;Loguit&lt;/a&gt;
     &lt;/p&gt;
     &lt;h2&gt;Projecten:&lt;/h2&gt;
     &lt;table width="100%" border="1" style="border-collapse:collapse;"&gt;
        &lt;thead&gt;
           &lt;tr&gt;
              &lt;th&gt;&lt;a href="overzicht.php?sort=gebruiker"&gt;Gebruiker&lt;/a&gt;&lt;/th&gt;
              &lt;th&gt;&lt;a href="overzicht.php?sort=projectname"&gt;Project naam:&lt;/a&gt;&lt;/th&gt;
              &lt;th&gt;&lt;a href="overzicht.php?sort=aantaluren"&gt;Aantal uren&lt;/a&gt;&lt;/th&gt;
              &lt;th&gt;&lt;a href="overzicht.php?sort=datum"&gt;Datum:&lt;/a&gt;&lt;/th&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
           &lt;?php
              //SORT BY ASC OR DESC
  
              $sel_query="SELECT * FROM uren";
  
              if ($_GET['sort'] == 'gebruiker') {
                  $sel_query .= " ORDER BY gebruiker";
              }elseif ($_GET['sort'] == 'projectname') {
                  $sel_query .= " ORDER BY projectname";
              }elseif ($_GET['sort'] == 'aantaluren') {
                  $sel_query .= " ORDER BY aantaluren DESC";
              }elseif ($_GET['sort'] == 'datum') {
                  $sel_query .= " ORDER BY datum";
              }
  
              $result = mysqli_query($mysqli,$sel_query);
              while($row = mysqli_fetch_assoc($result)) {
              ?&gt;
           &lt;tr&gt;
              &lt;td align="center"&gt;&lt;?php echo $row["gebruiker"]; ?&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;?php echo $row["projectname"]; ?&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;?php echo $row["aantaluren"]; ?&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;?php echo $row["datum"]; ?&gt;&lt;/td&gt;
           &lt;/tr&gt;
           &lt;?php } ?&gt;
        &lt;/tbody&gt;
     &lt;/table&gt;
     &lt;form name="filter" method="POST" action="overzicht.php"&gt;
        "&lt;input type="hidden" name="uid" value="&lt;?php echo $uid; ?&gt;"&gt;
        SHOW POSTS FROM:
        &lt;input type"date" name="date"&gt;
        &lt;input type="submit" name="submit" value="Filter"&gt;
     &lt;/form&gt;
     &lt;?php
        //FILTER BUTTON
  
        if (isset($_POST['submit'])) {
          $uid = $_POST['uid'];
          $date = $_POST['date'];
          $filter = "WHERE DATUM(post_date) IS '$date'";
          $query = "SELECT * FROM uren $filter";
          $respost = mysqli_query($mysqli, $query);
        } else {
          $query = "SELECT * FROM uren";
          $respost = mysqli_query($mysqli, $query);
        }
        ?&gt;
  &lt;/body&gt;
  </code></pre>