AKEEL AHMED AKEEL AHMED - 2 years ago 89
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.


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

Answer Source

In Controller

Pass data to view as

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

In views

foreach ($states as $row)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download