如何在Codeigniter 中按顺序显示这样的代码
<ul id="sortable">
<?php
$query = $this->db->get('drag');
foreach ($query->result() as $row)
{
echo '<li class="ui-state-default" title="'.$row->main_category_id.'" data-id="'.$row->id.'">'.$row->feeld.' <button type="button" class="btn btn-danger delbtn" id="dlbtn" data-ids="'.$row->id.'"><i class="fa fa-trash" aria-hidden="true"></i></button></li>';
}
?>
您可以使用order_by函数。
$query = $this->db->order_by("id","DESC")->get('drag');
//you can use ASC or DESC
$this->db->order_by("created_at", "asc")->get->result_array();