【发布时间】:2021-07-07 18:52:44
【问题描述】:
嘿, 我有下一个代码:
<?php
$homeworks = $this->db->get_where('teme', array('school_id' => school_id(), 'status'=>'0'))->result_array();
foreach( $homeworks as $homework){
?>
<tr>
<td><?php echo $homework['teme_code']; ?></td>
<td><?php echo $homework['timestamp']; ?></td>
<td>
输出是:
| teme_code| timestamp|
| XX| 01.01.2020|
| XY| 03.01.2020|
| XZ| 02.01.2020|
但我想展示
| teme_code| timestamp|
| XX| 01.01.2020|
| XZ| 02.01.2020|
| XY| 03.01.2020|
我尝试了但没有用。
$query = $this->db->query('SELECT teme_code, status=0,timestamp FROM teme ORDER BY timestamp ASC');
foreach ($query->result_array() as $row)
{...
【问题讨论】:
-
您将 group by 与 order by 混为一谈,请阅读Ordering results
标签: php codeigniter