我知道我可以补充一下:
<form>
Search Google:
<input type="search" name="googlesearch">
</form>
但这只会让我搜索谷歌。
我希望人们能够在此列表中搜索名称。 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时,每个帐户名称周围都会有一个黑色边框
谢谢。
答案 0 :(得分:0)
我认为您的订单位于数据库中,因此您可以使用简单的搜索表单。
这样的事情:
<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";
}