-1

如何在 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>';
    }
    ?>

4

2 回答 2

0
//you can use ASC or DESC 
$this->db->order_by("created_at", "asc")->get->result_array();
于 2020-04-13T08:59:10.437 回答
0

您可以使用order_by功能。

$query = $this->db->order_by("id","DESC")->get('drag');
于 2020-04-13T07:56:45.687 回答