2015-02-12 104 views
0
的.html頁面

上的文字,我知道我可以補充一點:如何添加一個搜索欄搜索

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

但這隻會讓我搜索谷歌。

我希望人們能夠搜索名單上的名單。 http://graphicambi.tk/onlineemployees.html

我該怎麼做?

ALSO

我無法弄清楚在何處放置 太...

這裏是我的代碼的一部分:

} 

$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

你知道他們可以使用他們的瀏覽器的CTRL + F查找 – 2015-02-12 08:24:43

+0

是。只是想法ID試圖讓他們更容易大聲笑。 – 2015-02-12 08:56:32

回答

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"; 
} 
+0

謝謝。工作很好。 – 2015-02-12 08:56:06

+0

不客氣! – WilliamN 2015-02-12 09:30:09