过滤由 while 循环创建的 PHP 表

嘿,我有一个由 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>

Linpeipei1985 回答:过滤由 while 循环创建的 PHP 表

表格是由PHP创建的还是手动创建的,浏览器没有区别。您可以简单地错误地使用您找到的“javascript 版本”。你可以仔细尝试实现这个example of code

本文链接:https://www.f2er.com/2051.html

大家都在问