title: Filtering tables with Javascript [PHP/SQL]
body: <p>So I have an SQL query which pulls all data from a mysql table, called example:</p>
  
  <pre><code>function get_example($conn){
  
  $statement = "SELECT * FROM `example`";
  if ($result = $conn-&gt;query($statement)) {
  
      $rows = array();
      while($row = $result-&gt;fetch_array()){
  
          $rows[] = $row;
      }
      return $rows;
  } else {
      return 0;
  }
  }
  </code></pre>
  
  <p>I call this function in PHP and store the value in $example. I can then use a foreach to create a table of everything:</p>
  
  <pre><code>&lt;table&gt;
  
  &lt;tr&gt;
    &lt;td&gt;ID&lt;/td&gt;
    &lt;td&gt;Name&lt;/td&gt;
    &lt;td&gt;Description&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  foreach($example as $entry){
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $entry['id'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $entry['name'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $entry['description'] . "&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  ?&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>This is all simple enough and I can use a form with method POST to choose a value and filter the table accordingly (for eg, only show entires where the description field is a certain value).</p>
  
  <p>My question is, how do I filter this table using JS?</p>
  
  <p>I would want to have html buttons which, when clicked, call a function which changes the relevant  tags css property for visibility from hidden to visible.</p>
  
  <p>So - by default every  tag is listed int he table with visibility proeprty set to hidden. Then, when certain elements are clicked, the associated  elements are set to visible.</p>
  
  <p>Is this possible? My JS knowledge is limited so the more I look into it, the more it seems the PHP form may be the ssafest way to go</p>
  
  <p>Thanks</p>