Single MySQLI query to check for admin privileges I have this script on top of all pages to check if user is admin otherwise we kick him. The problem is that I don't know if I am using double resources with a double query and results. Can I make this code to be only 1 query and 1 result? Please read the comments in code to understand:

&lt;?php
session_start();
$identification = $_SESSION['session_name'];
include 'inc/database.php';
$query = "SELECT * FROM `members` WHERE `username` = '$identification' LIMIT 1";

// Here is the question about, we run first query to verify user

$result_1 = mysqli_query($database, $query);

// Now I am like obligated to query 2 times and get 2 results to make the While user_info $result_2 to work

$result_2 = mysqli_query($database, $query);

$privileges = mysqli_fetch_array($result_1, MYSQLI_ASSOC);
$user_level = $privileges["privs"];
if ($user_level=='ADMIN'){} 
else {
header('Location: security.php?error=missing correct privileges. user is not admin');
exit();
}

// If I set here to $result_1 it just does not work, I feel obligated to query 2 times and use more resources

while($user_info = mysqli_fetch_assoc($result_2))
{
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Zona de Pruebas&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
Username: &lt;?php echo $user_info['username']?&gt;, can be here because is admin&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
}
?&gt;
You do not need to re-fetch or use a while loop, simply reuse the array that you fetched the first time.

&lt;?php
session_start();
$identification = $_SESSION['session_name'];
include 'inc/database.php';
$query = "SELECT * FROM `members` WHERE `username` = '$identification' LIMIT 1";

$result = mysqli_query($database, $query);

$user_info = mysqli_fetch_array($result, MYSQLI_ASSOC);
$user_level = $user_info["privs"];
if ($user_level=='ADMIN'){} 
else {
  header('Location: security.php?error=missing correct privileges. user is not admin');
  exit();
}

?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Zona de Pruebas&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
Username: &lt;?php echo $user_info['username']?&gt;, can be here because is admin&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
}
?&gt;