passing sql query results from controller into view with code igniter
15:00 06 Feb 2011

So I'm having this problem, it should be pretty simple, but I don't know why I can't figure it out. I"m new to the whole idea of MVC, and I'm trying to pass a database query from my controller into a view and display the results in the view. The way I'm doing it now says "undefined variable, sql" when I load the view. This is what I have:

CONTROLLER

function make_login()
{
    //Select list of departments for dropdown
    $this->load->database();
    $sql = $this->db->query('SELECT departmentName FROM department ORDER BY departmentName ASC');



    $this->load->view('siteheader.php');
    $this->load->view('makelogin.php', $sql->result_array());
    $this->load->view('sitefooter.php');
}

VIEW

result_array() as $row)
    {
        echo $row['departmentName'];
    }
    ?>

(If I just echo it out in the controller, it displays the results)

Any help would be awesome... THANKS!

php codeigniter model-view-controller resultset