在表头添加过滤器

时间:2016-03-15 08:05:38

标签: php html mysql

我有html / php表显示来自数据库的数据我需要的是添加过滤器来排序表头上的数据

enter image description here

请告诉我如何添加过滤器来对列内的数据进行排序。这是我的代码:

<?php include_once 'includes/connection.php'; ?>
<h2>Facebook Forms</h2>
<hr><br>



<table border="4">
    <tr>


         <td bgcolor="#f6ff00">created time</td>
        <td bgcolor="#f6ff00">specialist</td>
        <td bgcolor="#f6ff00">full name</td>
        <td bgcolor="#f6ff00">city</td>
        <td bgcolor="#f6ff00">country</td>
        <td bgcolor="#f6ff00">date of birht</td>
        <td bgcolor="#f6ff00">phone number</td>
        <td bgcolor="#f6ff00">email</td>
    </tr>
   <?php
   // fetch all rows dynamic 
   $query   = "select * from forms";
   $result  = mysqli_query($conn, $query);
   while ($userSet = mysqli_fetch_assoc($result)){
       echo "<tr>";

       echo "<td>{$userSet['created_time']}</td>";
       echo "<td>{$userSet['specialist']}</td>";
       echo "<td>{$userSet['full_name']}</td>";
       echo "<td>{$userSet['city']}</td>";
       echo "<td>{$userSet['country']}</td>";
       echo "<td>{$userSet['date_of_birht']}</td>";
       echo "<td>{$userSet['phone_number']}</td>";
       echo "<td>{$userSet['email']}</td>";

       echo "</tr>";
   }
   ?>
</table>
<?php include_once 'includes/footer.php'; ?>

2 个答案:

答案 0 :(得分:0)

如果您想对数据进行排序,可以添加“按顺序”。 SQL语句中的子句如下:

public class MyNode extends DefaultMutableTreeTableNode {
    MyModel model;
    public MyNode(MyModel model){
        this.model= model;
    }
}

public MyTreeTableModel extends DefaultTreeTableModel{
...
}

public MyTreeTable extends JXTreeTable{
....
}
MyNode root = loading(...);
MyTreeTableModel tableModel = new MyTreeTableModel(root);
MyTreeTable myTree = new MyTreeTable(tableModel);

答案 1 :(得分:0)

您可以使用jq datatable查看它可能有用的网址https://datatables.net/