title: How can i apply the datatable filters to my php code?
body: <p>I am getting some data and displaying on the table which i have created in my php code however i want to apply the data table filters but i cannot seem to find a solution. I know in html i can assign an id to the table and then call it from a js script using the following code   var table = <code>$('#myTable').DataTable({"dom":"ftip"});</code> however this doesn't seem to work in my code. Perhaps because i am wrapping the html code in <code>php?</code></p>
  
  <p>Thanks</p>
  
  <p>
      
      
      
      </p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function(){
  
  
      var table = $('#myTable').DataTable({"dom":"ftip"});
  
  });
  
  &lt;/script&gt;
  
  &lt;?php
  
  $conn = mysqli_connect('localhost', 'root', '""', 'calendar');
  
  extract($_POST);
  
  if(isset($_POST['readrecords'])){
  
      $data =  '&lt;table class="table table-bordered table-striped" id="myTable"&gt;
                          &lt;tr class="bg-dark text-white"&gt;
                              &lt;th&gt;No.&lt;/th&gt;
                              &lt;th&gt;Title&lt;/th&gt;
                              &lt;th&gt;Driver&lt;/th&gt;
                              &lt;th&gt;Date&lt;/th&gt;
                          &lt;/tr&gt;';
  
      $displayquery = "SELECT id,title, driver, start FROM `events` ";
      $result = mysqli_query($conn,$displayquery);
  
      if(mysqli_num_rows($result) &gt; 0){
  
          $number = 1;
          while ($row = mysqli_fetch_array($result)) {
  
              $data .= '&lt;tr&gt;
                  &lt;td&gt;'.$number.'&lt;/td&gt;
                  &lt;td&gt;'.$row['title'].'&lt;/td&gt;
                  &lt;td&gt;'.$row['driver'].'&lt;/td&gt;
                  &lt;td&gt;'.$row['start'].'&lt;/td&gt;
                  &lt;td&gt;
                      &lt;button onclick="GetUserDetails('.$row['id'].')" class="btn btn-success"&gt;Edit&lt;/button&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;button onclick="DeleteUser('.$row['id'].')" class="btn btn-danger"&gt;Delete&lt;/button&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;';
              $number++;
  
          }
      }
       $data .= '&lt;/table&gt;';
          echo $data;
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>function readRecords(){</p>
  
  <pre><code>    var readrecords = "readrecords";
      $.ajax({
          url:"backend.php",
          type:"POST",
          data:{readrecords:readrecords},
          success:function(data,status){
              $('#records_content').html(data);
          },
  
      });
  }
  </code></pre>