AKEEL AHMED AKEEL AHMED - 7 months ago 13
SQL Question

Not able to access $result and my defiened $data[] array same time in Codeigniter view file

thnx in advance i m fetching some record from db and tring to send that result in view with some other data i have already. but not sure how to access that result value in drop down list.

Controller

$xap = $this->captchaGen();
$data['states'] = $this->Register_model->ListStates();
$data1 = array(
'captcha' => $xap['image'],
'message' => '',
'state' => $data
);
$this->load->view('login', $data1);


VIEW

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);

Answer

In Controller

Pass data to view as

 $xap=$this->captchaGen();
    $data['states'] = $this->Register_model->ListStates();
    $data['captcha'] = $xap['image'];
    $data['message'] = "";
    $this->load->view('login', $data);

In views

foreach ($states as $row)
{

}
Comments