PHP:Show<;td>;元素,如果某些条件为真
基本上,我需要有我的删除和编辑按钮,只有在管理员登录列可见,我知道如何确定是否有管理员登录。有没有办法回显需要显示的标签?提前谢谢PHP:Show<;td>;元素,如果某些条件为真,php,if-statement,html-table,Php,If Statement,Html Table,基本上,我需要有我的删除和编辑按钮,只有在管理员登录列可见,我知道如何确定是否有管理员登录。有没有办法回显需要显示的标签?提前谢谢 <table> <tr> <th>ID</th> <th>Full Name</th> <th>Email Address</th> <th>Add
<table>
<tr>
<th>ID</th>
<th>Full Name</th>
<th>Email Address</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip Code</th>
<th>Status</th>
<th>Edit?</th>
<th>Delete?</th>
</tr>
<?php foreach ($users as $user) : ?>
<tr>
<td><?php echo $user->getUser_id();?></td>
<td><?php echo $user->getFirstName().' '.$user->getLastName();?></td>
<td><?php echo $user->getEmailAddress(); ?></td>
<td><?php echo $user->getAddress();?></td>
<td><?php echo $user->getCity(); ?></td>
<td><?php echo $user->getState(); ?></td>
<td><?php echo $user->getZipCode(); ?></td>
<td><?php echo $user->getActiveDescription();?></td>
these two <td> should only be shown if x is true:
<td>
<form action ="" method="post">
<input type="hidden" name="controllerRequest"
value="show_user_edit">
<input type="hidden" name="user_id"
value="<?php echo $user->getUser_id(); ?>"/>
<input type="submit" value="Edit"></form>
</td>
<td>
<form action="" method="post">
<input type="hidden" name="controllerRequest"
value="delete_user">
<input type="hidden" name="user_id"
value="<?php echo $user->getUser_id(); ?>"/>
<input type="submit" value="Delete" id="red">
</form>
</td>"
;
}
}
?>
</tr>
<?php endforeach; ?>
</table>
身份证件
全名
电子邮件地址
地址
城市
陈述
邮政编码
地位
编辑
删除?
仅当x为真时,才应显示这两个值:
您需要使用
和
参见:是的,这是我的if语句:if(isset($\u SESSION['User']){$adminOrNo=$\u SESSION['User']->getWlUserRoleID();if($adminOrNo==2){****这是两个按钮需要出现的地方*****}