此代码向所有用户显示所有MySQL表数据但我只希望admin和user显示mysql查询数据
我有多个用户
1.admin
2.user123
3.xyz
所以我只想让管理员和用户显示MySQL表数据我该怎么做
示例 如果admin和user123打开页面然后mysql数据显示正确,如果xyz用户打开页面,那么它将不会显示任何数据
user login name <?php echo $_SESSION['SESS_FIRST_NAME']; ?>
我想将这个添加到mysql查询中以仅显示结果admin和user
$query = "SELECT * FROM `follower` WHERE `followername` LIKE '".$letter."%' ORDER BY `followername` ASC LIMIT $from, $max_results";
完整代码
<?php
$max_results = 10;
$from = (($page * $max_results) - $max_results);
if(empty($_POST)) {
$query = "SELECT * FROM `follower` WHERE `followername` LIKE '".$letter."%' ORDER BY `followername` ASC LIMIT $from, $max_results";
}
$result = mysql_query("SET NAMES utf8"); //the main trick
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
echo "<table class='gridtable' border='1' cellpadding='0' cellspacing='0'>";
echo "<tr><th>Name</th><th>Company Name</th><th>Mobile No</th></tr>";
if ($rows > 0) {
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['followername'];
echo "</td><td>";
echo $row['companyname'];
echo "</td><td>";
echo $row['mobileno'];
echo "</td><td>";
echo $row['contractdatee'];
echo "</td></tr>";
}
} else {
echo "<tr><td align=\"center\" colspan=\"4\">No results found!</td></tr>";
}
echo "</table>";
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as followername FROM follower ORDER BY followername ASC"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "<p class=\"style2\">Pages: ";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$prev&letter=$letter\" class=\"style2\">Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo " ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next&letter=$letter\" class=\"style2\">Next</a>";
}
echo "</p>";
mysql_close();
?>