【发布时间】:2021-08-09 17:06:55
【问题描述】:
这是我目前所拥有的(没有做任何事情)
<input type="text" id="search" " placeholder="Search..">
<table id='table'>
<!-- INVENTORY TABLE -->
<?php
$query = "SELECT * FROM StatesboroSwitchActive";
$result = mysqli_query($db, $query);
$count = 0;
echo "
<tr>
<th></th>
<th></th>
<th>Name</th>
<th>Model</th>
<th>Serial</th>
<th>MAC</th>
<th>Type</th>
<th>Notes</th>
<th>Cisco Notes</th>
<th>Location</th>
</tr>";
while ($row = mysqli_fetch_array($result)) {
$count++;
echo "<tr><td>" . "<button id='delete'>RMA</button>" .
"</td><td>" . "<button id='modify'>Modify</button>" .
"</td><td>" . $row['Name'] .
"</td><td>" . $row['Model'] .
"</td><td>" . $row['Serial'] .
"</td><td>" . $row['MAC'] .
"</td><td>" . $row['Type'] .
"</td><td>" . $row['Notes'] .
"</td><td>" . $row['Cisco Notes'] .
"</td><td>" . $row['Location'] . "</td></tr>";
}
echo "<h3>Total: " . $count . "</h3>";
?>
我希望能够使用搜索框将该表格过滤到用户输入的内容中。我现在很迷茫
【问题讨论】:
-
我会为你推荐一些javascript,例如w3schools.com/howto/howto_js_sort_table.asp
-
如果您正在使用表格,请查看:datatables.net
-
它与 MySQL 或 PHP 有什么关系?在我看来,您在问如何在用户界面中为 HTML 表实现过滤器
-
你真的应该在你的 SELECT 查询中添加一个 LIMIT。
标签: php html mysql html-table