php - Hide columns if user want that -
this has super simpel solutions, can't wrap head around it.
i have sql query:
select traning.type_name,users.user_id, users.user_name,user_traning.min_puls, user_traning.medel_puls,user_traning.max_puls, user_traning.duration,user_traning.date, user_traning.view traning inner join user_traning on traning.tr_id=user_traning.tr_id inner join users on user_traning.user_id=users.user_id order `user_traning`.`date` desc
i have colum in user_traning called view
.
the input form inputs either null
or 2
. im thinking null means view input, , 2 user want hide input.
i have been trying way:
while($row = $users_traning->fetchobject()) { if($row->user_id == $_session['user_id'] && $row->view == null) { echo '<span class="glyphicon glyphicon-user"></span> <a href="userinfo.php='.$row->user_id.'">you </a> have ' .$row->type_name. ' ' .round($minuter,2). ' min'; echo '<br>'; }else{ echo '<span class="glyphicon glyphicon-globe"></span> <a href="userinfo.php='.$row->user_id.'">'.$row->user_name.' </a> has been ' .$row->type_name. ' ' .round($minuter,2). ' for'; echo '<br>'; }}
as can see; if user has selected hide input (inserted 2) row displayed glyphicon-user, if not, displayed glyphicon-globe.
i want output everything, except rows other users have inserted 2
in column view. "own" rows still displayed corresponding glyphicons.
how can this?
help appreciated!
let assume user1 has been logged in..
while($row = $users_traning->fetchobject()) { if($row->user_id == $_session['user_id']){ //for user1 $glyphicon = (empty($row->view)) ? 'user' : 'globe' ; // if $row->view null 'user' assigned else 'globe' echo '<span class="glyphicon glyphicon-'.$glyphicon.'"></span> <a href="userinfo.php='.$row->user_id.'">you </a> have ' .$row->type_name. ' ' .round($minuter,2). ' min'; echo '<br>'; }elseif($row->user_id != $_session['user_id'] && empty($row->view)){ // user2 echo '<span class="glyphicon glyphicon-globe"></span> <a href="userinfo.php='.$row->user_id.'">'.$row->user_name.' </a> has been ' .$row->type_name. ' ' .round($minuter,2). ' for'; echo '<br>'; } }
Comments
Post a Comment