douwei6478 2016-06-23 15:35 采纳率: 100%
浏览 16
已采纳

数据库表过滤[关闭]

UPDATE: Sorry I'm new on here so i did not know the guidelines

This is what i have done so far

<!DOCTYPE HTML>
<html>
<head>
 <meta charset="utf-8">
 <title>AJAX filter demo</title>
</head>

<body> 
  <h1>Temporary Database</h1>

   <table id="employees">
    <thead>
    <tr>
         <th>ID</th>
      <th>Name</th>
      <th>Age</th>
      <th>Address</th>
      <th>Car</th>
      <th>Language</th>
      <th>Nights</th>
      <th>Student</th>
      </tr>
    </thead>
    <tbody>
    </tbody>
  </table>

    <script src="http://code.jquery.com/jquery-latest.js"></script> 
     <script>
    function makeTable(data){
     var tbl_body = "";
      $.each(data, function() {
        var tbl_row = "";
        $.each(this, function(k , v) {
          tbl_row += "<td>"+v+"</td>";
        })
        tbl_body += "<tr>"+tbl_row+"</tr>";                 
      })

      return tbl_body;
  }

  function updateEmployees(){
    $.ajax({
      type: "POST",
      url: "submit.php",
      dataType : 'json',
      cache: false,
      success: function(records){
        $('#employees tbody').html(makeTable(records));
      }
      });
      }

    updateEmployees();
   </script> 
 </body> 
  </html>

which outputs the table now in regards of client-side filtration i think is what I'm looking for. how would i go about filtering each column with a dropdown to output specific data unlike if i had a checkbox? Thank you

  • 写回答

1条回答 默认 最新

  • dongming4994 2016-06-23 15:50
    关注

    Use PHP to generate the table and html, then possibly use the jquery plugin https://datatables.net/, it allows you to easily create dynamic tables using javascript and jquery. It will save you a lot of time and effort.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案