php - A better way to check if a user were logged in and generate like dislike link -


i have script takes 500 rows table, , based on whether or not user logged in, generates link or dislike item.

the way goes this:

//select * table;  //while(){     if($userlogged)     {         echo $row['columnname'].' - dislike';     }else{         echo $row['columnname'];     } } 

this way, checks if user logged @ each , every row. $userlogged set in file that's included on page. better way instead of checking if user logged in inside loop each , every row?

not getting question quiet think want prevent condition each time loop can check condition first , loop accordingly, example

if($userlogged) {    while(condition) {     } } else {    while(condition) {     } } 

this way don't have check condition inside loop each time loops


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -