显示3个不同行的3个不同列

I have a table structured as below:


leaveTypeID | employeeID | balance | status |

1 | AT0000004 |2 |1 |
2 | AT0000004 |1 |1 |
3 | AT0000004 |3 |1 |
1 | AT0000008 |2 |1 |
2 | AT0000008 |2 |1 |
3 | AT0000008 |2 |1 |

This is the table schema:


leaveTypeID(PK) | employeeID(PK) | balance | status |


Now I want to to display in my view Leave Balance of AT000004 as:

CL: 2 SL: 1 EL: 3

You can follow this example:

Your Model:

public function modelFucntion(){
    $this->db->select('leaveTypeID,balance');
    $this->db->from('table');
    $this->db->where('employeeID','AT0000004');
    $query = $this->db->get();
    return $query->result_array();
}

Your Controller:

$data['result'] = $this->model_yourModel->modelFucntion(); // calling function.
$this->load->view('viewHTML', $data); // load view

Your View:

if(count($result) > 0){
    foreach ($result as $key => $value) {
        if($value['leaveTypeID'] == 1){
            echo "CL : ".$value['balance'];
        }
        if($value['leaveTypeID'] == 2){
            echo "SL : ".$value['balance'];
        }
        if($value['leaveTypeID'] == 3){
            echo "EL : ".$value['balance'];
        }
    }
}