数组返回空白

i have solve the error from the code but now the array it return in blank any idea of the problem can some one give a little hand on it please the code is

<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
    header("Location: index.php");
}

$res=mysql_query("SELECT user_level FROM users where user=".$_SESSION['user']);

while($rows=mysql_fetch_array($res)){
echo $rows['user_level'];

// close while loop 
}
die();
?>

Do the same thing like this way:

session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user'])){
    header("Location: index.php");
}
$user = $_SESSION['user'];
echo $sql = "SELECT user_level FROM users where user='".$user."'";
$res=mysql_query($sql);
$count = mysql_num_rows($res);
if($count > 0){
    while($rows = mysql_fetch_array($res)){
        echo $rows['user_level'];
        // close while loop 
    }
    die();
}else{
    echo 'No rows.';
}