gpt4 book ai didi

php - Codeigniter:分组依据并从连接表中获取最新记录

转载 作者:行者123 更新时间:2023-11-29 05:21:30 25 4
gpt4 key购买 nike

$this -> db -> select('users.*');
$this -> db -> select('timerecord.*');
$this -> db -> from('users');
$this -> db -> join('timerecord', 'users.id = timerecord.id');
//$this -> db -> where(array('users.id'=>$user_id), NULL, FALSE);
$this -> db -> where('users.status', 'Verified');
//$this -> db -> where('users.id', 'timerecord.id');
$this -> db -> order_by('timerecord.timeId', 'DESC');
$this -> db -> group_by('timerecord.id, users.id');

我想从用户和 timerecord 表中获取记录,但 timerecord 由于重复的 id 而显示多行,现在我使用 group_by 来限制 timerecord 中的行但是记录没有显示最新记录我也使用了 orderby 但没有运气好,请有人帮助我,谢谢!

最佳答案

<div class="container">
<script type="text/javascript">
$(document).ready(function(){
$('.approve').click(function(){
return confirm("Verify this user?");
});
$('.delete').click(function(){
return confirm("Are you sure you want to delete this account, everything will be deleted including its time record?");
});
});
</script>
<div class="empRec">
<div class="empRec-content">
<table class="tn">
<tr>
<th class="tn-4apw">Employee Name</th>
<th class="tn-4apw">Date</th>
<th class="tn-4apw">Day</th>
<th class="tn-4apw">Time In/Out</th>
<th class="tn-4apw"></th>
</tr>
<?php
foreach($getUsers as $row):
$timeStat = $row->status;
?>
<tr>
<td class="tn-ixdt"><?php if($timeStat == 'IN') { ?>
<img src="<?php echo base_url('assets/img/ico-online.png'); ?>" style="width:10px;">
<?php } else { ?>
<img src="<?php echo base_url('assets/img/ico-offline.png'); ?>" style="width:10px;">
<?php } echo $row->name ?></td>
<td class="tn-ixdt"><?php echo $row->dateToday ?></td>
<td class="tn-ixdt"><?php echo $row->day ?></td>
<td class="tn-ixdt"><?php echo $row->timeIn ?> - <?php echo $row->timeOut ?></td>
<td class="tn-ixdt" style="text-align:right;"><button class="view" name="view"><img src="<?php echo base_url('assets/img/ico-view.png'); ?>"></img></button><button class="delete" name="delete"><img src="<?php echo base_url('assets/img/ico-delete.png'); ?>"></img></button></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<!-- Employee Record Content -->
<div class="empRec-bg"></div>
</div>
<!-- EMPLOYEE RECORD CONTAINER -->
</div>
<!-- CONTAINER -->

关于php - Codeigniter:分组依据并从连接表中获取最新记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25303858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com