我目前正在研究codeigniter。我想显示一个不重复的值,或者将mysql数据库中的重复值覆盖到php foreach循环的数据表中。如何避免显示重复值或覆盖重复值在PHP foreach循环表中?
下面是表代码:
<table class="table table-striped responsive-utilities jambo_table" id="myTable">
<thead>
<tr class="headings">
<th>Employee No.</th>
<th>Username</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach($EMPLOYEES as $employee){?>
<tr>
<td><?php echo $employee->empnum; ?></td>
<td><?php echo $employee->username; ?></td>
<td><?php echo $employee->name; ?> <?php echo $employee->lastname; ?></td>
<td><?php
if ($employee->hasClockOut==1){
echo '<a class="label label-danger">Inactive</a>';
}else {
echo '<a class="label label-success">Active</a>';
}
?></td>
</tr>
<?php } ?>
</tbody>
</table>
你为什么不只能选择唯一值,在查询 –
它不正常工作。 – Jorge
对您的数据和预期结果的解释可能有助于澄清您的需求并为您提供更准确的答案。 “不起作用”真的很少解释。 – Niagaradad