嗨,我已經可以進行搜索。現在我想如何根據他們的角色放置這些數據,基於這張圖片我想讓管理員,管理員,用戶,用戶,用戶。需要使用排序?我不知道。根據用戶角色排序我的顯示數據
,這我的編碼搜索。我應該在哪裏排序?
<?php
include 'config1.php';
if(isset($_POST['search'])){
$searchTerm = $_POST['search'];
$query = "SELECT * FROM members WHERE userid LIKE '%$searchTerm%'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
echo "<table height = '30%'border='1'>";
if($count == 0)
{
echo "NO ID REGISTERED!";
}
else
{
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td width='5%'><b>USER ID:</b> {$row['userid']} </td>";
echo "<td width='5%'><b>USER NAME :</b> {$row['username']} </td>";
echo "<td width='5%'><b>USER EMAIL:</b> {$row['useremail']} </td>";
echo "<td width='5%'><b>USER ROLE:</b> {$row['userrole']} </td>";
echo "<td width='5%'><b>USER DIVISION:</b> {$row['userdiv']} </td>";
echo "<td width='5%'><b>USER DEPARTMENT:</b> {$row['userdepartment']} </td>";
echo "</tr>";
}
}
echo"</table>";
}
?>
使用'ORDER BY上的查詢userrole',並考慮開溝'mysql_'功能,並與'mysqli_ *'或'PDO'與替換它們的方法制得的語句(http://stackoverflow.com/questions/12859942/why-shouldnt -i-use-mysql-functions-in-php/12860140#12860140) – Ghost 2014-08-28 07:14:20
我應該在哪裏放ORDER BY? – lightyagami 2014-08-28 07:14:54
你能給我完整的編碼嗎? – lightyagami 2014-08-28 07:15:10