$num_rows outputs an integer and not a string. Remove the double quotes around your comparison values...
$db_connect = mysql_connect("localhost", "username", "password");
mysql_select_db("dbname", $db_connect);
$result = mysql_query("SELECT rank FROM yellow_page_listings WHERE username = '$username' ", $db_connect);
$num_rows = mysql_num_rows($result);
if($num_rows == 1)
{
echo "userlevel 1";
}
elseif($num_rows == 2)
{
echo "userlevel 2 ";
}
else{
echo "you have no account";
}
(This should work for you, assuming your query is right, and you are actually getting rows returned.)