I'm trying to display the content of the fields of my "projects" table on the index page but cant seem to get it working. What am I doing wrong here?
Model:
public function prodView() {
$sql = 'SELECT * FROM projects';
$query = $this->db->query($sql);
return $query->result();
}
Controller:
public function index() {
$this->load->model('main_model');
$data ['query'] = $this->main_model->prodView();
$this->load_view('/index', $data);
}
View:
<?php foreach($query as $row): ?>
<tr>
<td><?php echo $row->project_name; ?></td>
</tr>
<?php endforeach; ?>