无法将数据加载到codeigniter中的组合框中


can not load data to combo box in codeigniter

可能重复:
PHP:"Notice:Undefined variable"answers"Notice:Undefined index">

我尝试从数据库加载组合框内容。但当我运行代码时,我得到了未定义的变量消息。我所做的是从数据库表和模型中加载数据,然后在控制器中使用它们来发送要查看的数据数组。

以下是控制器方法

public function loadcombo(){
       //Calling the getcombo_titel() function to get the arr of titles. Model already loaded.
        $arrStates = $this->dataOperateModel->getcombo_titel();
        print_r($arrStates);
        echo 'hiii';
        //Getting the final array in the form which I will be using for the form helper to create a dropdown.
        foreach ($arrStates as $job_name) {
            $arrFinal[$job_name->title] = $job_name->title;
        }
        $data['job_name'] = $arrFinal;
        $data['main_content']='home/welcome_message';
        print_r($arrFinal);
        //$data['states'] = $arrFinal;
        //$data['main_content']='user/index_view';
        //Passing $data to the view, so that we can get the states as an array inside the view.
        $this->load->view('layout',$data);

        }

这是视图中的代码

 <div class="content" id="desc" >Job title</div> <div id="cont" class="content">
                   <?php echo form_dropdown('job_name',$job_name); ?>
 </div>

错误中显示"Undefined variable: job_name"

这是型号的代码

 public function getcombo_titel(){
        $query = $this->db->query("SELECT DISTINCT title FROM combo_jobtitle");
        if ($query->num_rows > 0) {
            return $query->result();
        }
   }

有人能说出我在哪里犯的错吗?

问题出现在sql查询中。我把tittle这个词拼错了。对不起,伙计们。