在提示列表中,编辑按钮仅显示自己的提示
<?php
$this->session->all_userdata();
$id = $this->session->userdata('user_id');
$data['user_id'] = $id;
$i=1;
foreach ($tips->result() as $row)
{ ?>
<tr>
<td><?php echo $i++;?></td>
<td><?php echo $row->tips_desc;?></td>
<td><?php if (isset($row->user_id)==='$id'){ ?> <a href="<?php echo site_url('index.php/Doctor/tips_update/'.$row->tips_id); ?>" ><span class="glyphicon glyphicon-pencil"style="color:green";></span></a><?php }else {echo"not";}?></td>
答案 0 :(得分:0)
关注您的代码,是建议:
<?php
if (isset($row->user_id)==='$id'){ ?> <a href="<?php echo site_url('index.php/Doctor/tips_update/'.$row->tips_id); ?>" ><span class="glyphicon glyphicon-pencil" style="color:green";></span></a><?php }else {echo"not";}?></td>
首先,isset()函数返回TRUE
或FALSE
。
1)您正在比较isset()
为TRUE或FALSE与$ id
2)$id
不应该有任何单引号,因为它不会评估。
所以,更正的声明:
<?php
if ($row->user_id === $id){
?>
<a href="<?php echo site_url('index.php/Doctor/tips_update/'.$row->tips_id); ?>">
<span class="glyphicon glyphicon-pencil"style="color:green";></span>
</a>
<?php
}
else {
echo "not";
}
?></td>