Live search is creating problem

/I made an API now I want a Live search option in GET method. It’s not working, please help./

[php]<?php
// create SQL based on HTTP method
switch ($method) {
case ‘GET’:

$sql = "select * from `$table`".($key?" WHERE id=$key":''); 
 $r_query = mysqli_query($link, $sql); 


//$getvalues = preg_split("/(=|&)/", $input);

?>

<!doctype html>

Simple jQuery Table Live Search
<style>
body { background-color:#F47265; font-family:'Roboto';}
.container { margin:150px auto;}
input { margin:50px auto;}
</style>

Simple jQuery Table Live Search

<table id="myTable" class="table table-inverse">
  <thead>
    <tr class="myHead">
 <!-- //<input type="text" placeholder="Search..." id="search_field"> -->
   <th>Username</th>
   <th>Email</th>
 <th>Mobile</th>
  <th>Address</th>
 <!--  <form method="get">
  <input type="hidden" name="subs" value='1'> 
   <input type="submit" value="Table" /> 
--> <?php while ($row = $r_query->fetch_object()) { ?>
<td>
  <?php echo $row->username;?>
 </td>
 <td>
  <?php echo $row->email;?>
 </td>
 <td>
  <?php echo $row->mobile;?>
 </td>
 <td>
  <?php echo $row->addrs;?>
 </td>
<?php }

?>

    <script src="js/index.js"></script>
<script type="text/javascript">

  $('#search_field').on('keyup', function() {
    var value = $(this).val();
    var patt = new RegExp(value, "i");

$('#myTable').find('tr').each(function() {
    if (!($(this).find('td').text().search(patt) >= 0)) {
      $(this).not('.myHead').hide();
    }
    if (($(this).find('td').text().search(patt) >= 0)) {
      $(this).show();
    }

  });
});
[/php]

[php]

    <script src="js/index.js"></script>
<script type="text/javascript">

  $('#search_field').on('keyup', function() {
    var value = $(this).val();
    var patt = new RegExp(value, "i");

$('#myTable').find('tr').each(function() {
    if (!($(this).find('td').text().search(patt) >= 0)) {
      $(this).not('.myHead').hide();
    }
    if (($(this).find('td').text().search(patt) >= 0)) {
      $(this).show();
    }

  });
});

//it was missing

[/php]

Need more information as I don’t actually see any questions. And API’s should not return html if they will last, the simply return data.

Sponsor our Newsletter | Privacy Policy | Terms of Service