09-25-2015, 12:38 PM
I am very new to CodeIgniter and struggling with piecing together my first CI site.
I am trying to use the Query Builder to get all the records from a database table called 'case_statuses'.
In my Model I have
In my Controller I have
and in my file I have
I did a var_dump of $case_status to see why I was getting an 'illegal offset' error message, and it looks like I am getting only one row of the table, instead of all six rows. What am I doing wrong?
I am trying to use the Query Builder to get all the records from a database table called 'case_statuses'.
In my Model I have
Code:
public function get_case_status() {
$query = $this->db->get('case_statuses');
return $query->row_array();
}
In my Controller I have
Code:
public function index() {
$data = array(
'page_title' => 'Restore CRM - Registration',
'body_class' => 'registration'
);
$data['case_status'] = $this->registration_model->get_case_status();
$this->load->view('includes/header', $data);
$this->load->view('registration');
$this->load->view('includes/footer');
}
and in my file I have
Code:
<select name="case_status_id" id="case_status">
<?php foreach ($case_status as $status) : ?>
<option value="<?php echo $status['id']; ?>"><?php echo $status['status']; ?></option>
<?php endforeach; ?>
</select>
I did a var_dump of $case_status to see why I was getting an 'illegal offset' error message, and it looks like I am getting only one row of the table, instead of all six rows. What am I doing wrong?