A better way to check if a user were logged in and generate like dislike link
<p>I have a script that takes some 500 rows from a table, and based on whether or not a user is logged in, generates a link to like or dislike the item.</p>

<p>The way it currently goes is like this:</p>

<pre><code>//Select * from table;

//while(){
    if($userLogged)
    {
        echo $row['columnName'].' Like - Dislike';
    }else{
        echo $row['columnName'];
    }
}
</code></pre>

<p>This way, it checks if a user is logged at each and every row. <code>$userLogged</code> is set in a file that's included on this page. 
What would be a better way to do this instead of checking if a user were logged in inside the loop for each and every row?</p>
