如何添加搜索栏以在 .html 页面上搜索文本

How can I add a search bar to search text on .html page

我知道我可以添加这个:

<form>
  Search Google:
  <input type="search" name="googlesearch">
</form>

但这只允许我搜索 google。

我希望人们能够在此列表中搜索名字。 http://graphicambi.tk/onlineemployees.html

我该怎么做?

还有

我不知道该放在哪里 也...

这是我的代码的一部分:

    } 

$sql = "SELECT userID, users_name, usertype, status FROM tbluseraccounts";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
    if($row["status"] == "Online"){
        $tcolor = "green";
    }
    elseif($row["status"] == "Offline"){
        $tcolor = "red";
    }
        echo "<br>ID: " . $row["userID"]. " <br> Name: " . $row["users_name"]. " <br> Account Type: " . $row["usertype"]. " <br> Status: <font color='".$tcolor."'>" . $row["status"]. "</font><br>";
     }
} else {
     echo "0 results";
}

哪里说:

echo "<br>ID: " . $row["userID"]. " <br> Name: " . $row["users_name"]. " <br> Account Type: " . $row["usertype"]. " <br> Status: <font color='".$tcolor."'>" . $row["status"]. "</font><br>";

我想在周围创建那个边框,这样当你访问这个网站时http://graphicambi.tk/onlineemployees.html每个帐户名称周围都会有一个黑色边框

谢谢。

我认为您的订单在数据库中,因此您可以使用简单的搜索表单。

像这样:

<FORM method="POST" action="search.php">
    <INPUT type="text" name="search">
    <INPUT type="submit">
</FORM>

在您的 search.php 文件中:

$sql = "SELECT userID, users_name, usertype, status FROM tbluseraccounts WHERE users_name LIKE %$_POST['search']%";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
    if($row["status"] == "Online"){
        $tcolor = "green";
    }
    elseif($row["status"] == "Offline"){
        $tcolor = "red";
    }
        echo "<br>ID: " . $row["userID"]. " <br> Name: " . $row["users_name"]. " <br> Account Type: " . $row["usertype"]. " <br> Status: <font color='".$tcolor."'>" . $row["status"]. "</font><br>";
     }
} else {
     echo "0 results";
}