title: Jquery, php, mysql table sorting using tablesorter
body: <p>I'm doing a very simple site on which I need to have a table sorting system, I've got the table set up, it feeds back data from MySQL table but I cannot seem to be able to sort rows, any ideas?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="main.css"/&gt;
  &lt;title&gt;Assessment 2&lt;/title&gt;
      &lt;script type="text/javascript" src="jquery-1.11.1.min.js"&gt;&lt;/script&gt; 
      &lt;script type="text/javascript" src="jquery.tablesorter.js"&gt;&lt;/script&gt; 
      &lt;script type ="text/javascript"&gt;
  
          $(document).ready(function() 
              { 
                  $("products").tablesorter(); 
              } 
          ); 
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;?php
        include '\navigation\navigation.php';
      ?&gt;
  
  &lt;div class="center"&gt;
      &lt;h1&gt;Products&lt;/h1&gt;
  
  
  
      &lt;?php
          include "connectionlocalhost.php";
  
  
          $query = "SELECT * FROM products";
          $result = mysqli_query($connection, $query) or exit ("Error $query . ".mysqli_error());
  
              echo "&lt;table border='1' id='products' class='tablesorter'&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Product Name&lt;/th&gt;
                      &lt;th&gt;Product Price&lt;/th&gt;
                      &lt;th&gt;Product Image&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;";   
  
          while ($row = mysqli_fetch_assoc($result)){
              echo "&lt;tr&gt;";
              echo "&lt;td&gt;". $row['productname'] . "&lt;/td&gt;";
              echo "&lt;td&gt;". $row['productprice'] . "&lt;/td&gt;";
              echo "&lt;/td&gt;";
  
              }
              mysqli_free_result($result);
  
  
  
          echo "&lt;/tbody&gt;&lt;/table&gt;";
  
      ?&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am aware that one of columns is empty, its just for testing purposes, I thought there was an error with mysql query.</p>