jeudi 8 septembre 2016

if-else statement not working correctly in while loop

I'm not sure what exactly I'm doing wrong here. I'd like to get an extra link if a user is an admin, and the link should be void if the user is a member. But I get the extra link that should be for admins only even if I'm logged in as a member. What am I doing wrong in my code?

$connect=mysqli_connect("$db_server", "$db_user", "$db_password", "$db_database");
$query="SELECT admin FROM `$table_members`";
$result=mysqli_query($connect, $query);
while ($row=mysqli_fetch_assoc($result)) {
    $admin = $row['admin'];
    if ($admin=="Administrator") {
        echo "<a href=\"admin.php\">Admin Panel</a>";
    }
    else {
        echo "";
    }
}

Thanks for the help in advance!

Aucun commentaire:

Enregistrer un commentaire