在codeigniter中查看传递数组不起作用

So my problem is that the values from this specific id won't print. I really don't know what's the problem since there is no error. please help guys. Still a newbie at using this framework. thanks!

controller:

public function teacher(){
  $this->load->model('model_teacher');
  $id = $this->input->post('idnum');  
  $data['result'] = $this->model_teacher->scoreboard($id);

  $this->load->view('teacher/teacher', $data);
 } 

model:

class Model_teacher extends CI_Model {

    public function scoreboard($id) {

        //$this->db->where('login_id', $this->input->post('idnum'));
        $query = $this->db->query("SELECT * FROM teacher WHERE login_id = '".$id."'");
        return $query->result();

        }
} 

view:

 <?php
    foreach ($result as $a) {
            echo $a['login_id'];
            echo $a['lname'];
            echo $a['mname'];
            echo $a['fname'];
        }

 ?>

Alternative to Ghost's answer:

To keep you model the same you would just need to change your view file from:

foreach ($result as $a) {
        echo $a['login_id'];
        echo $a['lname'];
        echo $a['mname'];
        echo $a['fname'];
    }

To:

foreach ($result as $a) {
        echo $a->login_id;
        echo $a->lname;
        echo $a->mname;
        echo $a->fname;
    }

This is because result() with the DB driver returns an array of Objects where as result_array() returns an array of arrays.

Hope this helps!