php - if-else statement not working correctly in while loop
Solution:
I can't see any query which make the difference b/w admin and member, your code simply retrieving admin column and going through every value and printing the link whenever it matches.
Don't you think your query would be something like with a unique key plus you need to only check once instead of while loop
$query="SELECT admin FROM `$table_members` where id='uniqueid'";
or
$query="SELECT admin FROM `$table_members` where userID_email='uniqueid'";
$result=mysqli_query($connect, $query);
$row_cnt = mysqli_num_rows($result); // see if match found
if($row_cnt>0) { // if false mean unknown user
$row=mysqli_fetch_assoc($result);
$admin = $row['admin'];
if ($admin=="Administrator") {
echo "<a href=\"admin.php\">Admin Panel</a>";
}
else {
echo "";
}
}
Answer
Solution:
First of all your connection is problem
1)remove all double quotes in mysqli_connection parameters .your passing variable as parameter if you give double quotes it treated as string so remove double quotes