显示来自数据库php的嵌套列表

Sorry for asking the same old question again. I found some relevant to my question but nothing solves my problem. I know the logic on how to do this but the problem is I can't get it in my code.

I wanted to display all the items from Items table. Items with a type=section will be the parents of all sub-items. Now, how can I group all the items from their designated parent list and display them as a sub-list below the parent?

Controller:

public function show_item () { 
  $data = array(
   'items' => $this->checklist_item_model->get_specific_item($id),
   'checklist_info' => $this->checklist_item_model->get_checklist_info($id)
   );
}

Model:

 public function get_specific_item ($id) {
  $output = $this->db->get_where('checklist_items', array('checklist_id' => $id));
  return $output->result_array();
 }

 public function get_checklist_info($id) {
  $query = $this->db->get_where('checklists', array('id' => $id));
  $result = $query->result_array ();
  return $result;
 }

View:

<ul class="list-group list-group-sortable list-group-root">
<?php foreach ($items as $key => $value):?>
  <li class="list-group-item" draggable="true">
  <?php echo $value['type'] == 'section' ? $value['title'] : '' //display the parent items where type is equal to section?> 
  </li>
   <ul class="list-group list-group-sortable">
   <li class="list-group-item list-group-sortable"><i class="fa fa-ellipsis-v"></i>
    <span class="badge <?php echo 'badge'.'-'.$value['status']; ?>">
    <?php  echo ($value['status'] == 'pending' ? 'Pending' : ($value['status'] == 'complete' ? 'Complete' : 'Incomplete')) ?>
    </span>
    <a href="#" onclick="manage_item('<?php echo count($items); ?>, <?php echo $value['title'] ?>')">
    <?php if($value['type'] !== 'section') {
     echo $value['title']; //display all items as a sublist belong to a parent list
     } ?>
     </a>
    </li> 
   </ul>                       
 <?php endforeach; ?>

Cheklist_item table: enter image description here

Is it okay to put a parent_id always equal to 0 when an item is equal to 0? And note that order_no will be the order of the list from their parent. Any help would be very very much appreciated.