I have a 'users' table in my Database (currently 4 users) that contains different roles (1 = user, 2= admin, 3= moderator). I want to show some lines of my php script only to admins and moderators, so I made this query: (I know it is not secure)
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$stuff = 'SELECT * FROM `users` WHERE role > 0';
$result = mysqli_query($conn, $stuff);
This query list all users with the role over 0.
require_once('link_to_script.php');
if (mysqli_num_rows($result) >1){
echo "Admin area";
}else{
echo "No Permissions";
}
This should be self explaining (only show "Admin area" to users with role higher than 1)
I don't know what my mistake is and I hope someone could help me a little bit :)