如何检查,如果在上一行 exit_status
中完成,并且根据它是否完成或挂起显示更新更新按钮,或者将其隐藏在 CodeIgniter 中。我想不出实现这个的逻辑,这是我的 View 代码:
<?php } else if($USER->permissions[0] == 'all' && $row['responsibility'] == $USER->email && $row['completion_status'] == 'Pending'&& $row['sequence']-1 == 'completed') { ?>
<td style="width:10%">
<input type="hidden" name="grievance_id" value="<?=$row['id']?>">
<input type="hidden" name="action" value="update">
<input type="submit" <?=($row[ 'checklist_id']=="Denied" ||$row[ 'checklist_id']=="Approved" )? "disabled='true'": "";?>name="sumit_button" value="Update" class="btn" style="float:left;background:#d8d8d8;color:#000;box-shadow:0px 0px 1x rgba(0,0,0,0.2)!important;">
</td>
<?php }
如果前一行 exit_status 完成,则打开更新按钮,否则隐藏它。像.. if($row['sequence']-1) == 'completed' {display the button else hide} 。附加 View 图像
最佳答案
如果我没理解错的话——你想访问 foreach 中之前的“Row”值
为了做到这一点,你可以尝试这样的事情
我假设你的键是数字并且从 0 开始
if(count($rows) > 0)
{
foreach($rows as $key => $row)
{
$prevRow = (isset($rows[($key-1)])) ? $rows[($key-1)] : false;
if($USER->permissions[0] == 'all' && $row['responsibility'] == $USER->email && $row['completion_status'] == 'Pending'&& ($prevRow && $prevRow['sequence'] == 'completed'))
{
//your code goes here
}
}
}
更好的解决方案是实现一个ArrayIterator http://php.net/manual/de/class.arrayiterator.php
关于javascript - 检查前一行值并相应地显示下一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39264727/