[eluser]Captain_Fluffy_Pants[/eluser]
trying to load mysql database and its not working
controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
function Site(){
parent::_construct();
}
function all(){
$this->load->model('posts');
$data['rows'] = $this->posts->load_all();
$this->load->view('pages/view_all', $data);
}
}
view
Code:
<ol>
<? foreach($row as $row): ?>
<li><?= $row->title ?></li>
<? endforeach; ?>
</ol>
model
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Posts extends CI_Model {
function __construct() {
parent::__construct();
$this->load->database();
}
function load_all() {
$query = $this->db->get('posts');
return $query->result();
}
}
anyone know what i did wrong?