尝试将数据从db插入CodeIgniter中的下拉列表时显示错误

时间:2014-03-12 16:18:16

标签: codeigniter

显示以下错误:......................................... ....

    Severity: Notice
    Message:  Undefined variable: groups
    Filename: views/content_view.php
    Line Number: 10

请你帮助我......下面是我试过的代码

下面是我的控制器

**MY CONTROLLER**

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Delivery_controller extends CI_Controller{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('model_get');

    }
    public function delivery()
    {
        $data['groups'] = $this->model_get->getAllGroups();
        $this->load->view("site_header");
        $this->load->view("site_nav");
        $this->load->view('login');
        $this->load->view('content_view');  
        $this->load->view("content_video");
        $this->load->view("site_footer");
    }


}
?>

below is my view
**MY VIEW**


<div id="content" class="col-md-6">

            <h1> Comparison</h1> 


             <select class="form-control">
                            <?php 

                            if (is_array($groups))
                                {
                                    foreach($groups as $row)
                                    { 
                                      echo '<option value="'.$row->page.'">'.$row->page.'</option>';
                                    }
                                }
                            ?>


            </select>

</div>

以下是该模型的相关信息 我的模特

        class Model_get extends CI_Model{
    public function __construct()
    {
        parent::__construct();
    }

    function getAllGroups()
    {

        $query = $this->db->query('SELECT page FROM pageData');


        return $query->result();

    }
}

1 个答案:

答案 0 :(得分:0)

尝试:

$this->load->view('content_view', $data);