控制器
$xap = $this->captchaGen();
$data['states'] = $this->Register_model->ListStates();
$data1 = array(
'captcha' => $xap['image'],
'message' => '',
'state' => $data
);
$this->load->view('login', $data1);
查看
foreach ($state as $row) {
$options[$row->name] = $row->name;
}
$js = 'id="c_stat" class="form-control"';
echo form_dropdown('c_stat', $options, set_value('c_stat'), $js);
答案 0 :(得分:1)
在控制器中
将数据传递给视图
$xap=$this->captchaGen();
$data['states'] = $this->Register_model->ListStates();
$data['captcha'] = $xap['image'];
$data['message'] = "";
$this->load->view('login', $data);
观看
foreach ($states as $row)
{
}
答案 1 :(得分:0)
**Try this**
In controller
$states = $this->Register_model->ListStates();
$data['captcha'] => $xap['image'];
$data['message'] => '';
$data['state'] => $states;
$this->load->view('login', $data);
And in view
foreach ($state as $value) {
}
传递$ data代替$ data1
$ this-> load-> view(' login',$ data1);
将其替换为
$ this-> load-> view(' login',$ data);