嘿,我有一个由 PHP while 循环创建的 HTML 表。为此,我想要一个可以搜索表格的输入。我在互联网上找到的普通 JavaScript 版本不起作用。我认为这是因为该表不在 HTML 源代码中,而是由 PHP 插入的。感谢您的回答,祝您有美好的一天!
<table class="table" id="searchtable">
<thead>
<tr>
<th scope="col">username</th>
<th scope="col">Rank</th>
</tr>
</thead>
<tbody>
<?php
require $_SERVER['DOCUMENT_ROOT'].'/req/config.php';
$stmt = $sql->prepare("SELECT * FROM users");
$stmt->execute();
while ($result = $stmt->fetch()) {
?>
<tr>
<th scope="row"><?php echo $result["username"] ?></th>
<th><?php echo $result["rank"] ?></th>
</tr>
<?php
}
?>
</tbody>
</table>