0

I'm trying to create a page that displays all the data from my database, but I'd like the ability to live filter the data through a search box, eliminating rows that don't match the query, almost exactly like DataTables. I can't use DataTables, however, because I'm finding it difficult to add the custom columns I have. I know how to make a search page that then displays results but not how to search within results.

Any help would be appreciated. Thanks.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
        <title>View Records</title>
</head>
<body>

<?php

        // connect to the database
        include('connect-db.php');


        // get results from database
        $result = mysql_query("SELECT * FROM Orders") 
                or die(mysql_error());      

        // display data in table        
        echo "<table border='1' cellpadding='10'>";
        echo "<tr> <th>Date</th> <th>Name</th> <th>Phone</th> <th>Location</th> <th></th> <th></th></tr>";

        while($row = mysql_fetch_array( $result )) {
     $src = '';
     switch( $row['Location'] ) {
          case '1':
              $src = '1.jpg';
              break;
          case '2':
              $src = '2.jpg';
              break;
          default:
              $src = 'default.jpg';

            }      // echo out the contents of each row into a table
                echo "<tr>";
                echo '<td>' . $row['date'] . '</td>';
                echo '<td>' . $row['Name'] . '</td>';
                echo '<td>' . $row['Phone'] . '</td>';
                echo '<td><img src="'.$src.'"></td>';
                echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
                echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
                echo "</tr>"; 
        } 

        // close table>
        echo "</table>";


?>
<p><a href="new.php">Add a new record</a></p>

</body>
</html>
user2208768
  • 25
  • 1
  • 8

1 Answers1

0

Using jQuery for client side table search

Community
  • 1
  • 1
Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196