-1

How can display thus code in order by in 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>';
    }
    ?>

Dum
  • 1,431
  • 2
  • 9
  • 23

2 Answers2

0

You can use order_by function.

$query = $this->db->order_by("id","DESC")->get('drag');
Dum
  • 1,431
  • 2
  • 9
  • 23
0
//you can use ASC or DESC 
$this->db->order_by("created_at", "asc")->get->result_array();
PHP Geek
  • 3,949
  • 1
  • 16
  • 32