Author Topic: Undefined Table Data?  (Read 531 times)

0 Members and 1 Guest are viewing this topic.

Offline JakebertTopic starter

  • Irregular
  • Posts: 32
    • View Profile
Undefined Table Data?
« on: November 10, 2009, 11:58:06 AM »
OK, here's the problemo:

Controller:
Code: [Select]
<?php

class Student extends Controller {

function index() {

$site['main_content'] = 'student_admin_view';

$this->load->library('pagination');
$this->load->library('table');
$this->load->model('students_model');

//$this->table->set_heading('Id', 'The Title', 'The Content');

$config['base_url'] = 'http://localhost:8888/ci/index.php/student/index';
$config['per_page'] = 10;
$config['num_links'] = 20;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$config['total_rows'] = $this->students_model->getRows();
$this->pagination->initialize($config);
$data['records'] = $this->students_model->paginate($config);


$this->load->view('student_admin_view'$data);

Model:

Code: [Select]
<?php

class Students_model extends Model {

function getAll() {

$q $this->db->get('students'); // same thing as SELECT * FROM students

if($q->num_rows() > 0) {
foreach ($q->result() as $row)
{
$data[] = $row;
}
return $data;
}


function add_student($data) {
$this->db->insert('students'$data);
return;
}

function update_student() {
$this->db->where('id'number);
$this->db->update('students'$data);
}

function delete_row() {
$this->db->where('id'$this->uri->segment(3));
$this->db->delete('students');
}

function getRows() {
$this->db->get('students')->num_rows();
return;
}

function paginate($config)
{
$this->db->get('students'$config['per_page'], $this->uri->segment(3));
return; 
}


}


Annnnd view:
Code: [Select]
<html...blah blagh blah>
<h2>Read</h2>
<div id = "container">
<?php echo $this->table->generate($records); ?>
<?php echo $this->pagination->create_links(); ?>

Here's what appears on index/student

Quote
Read
Undefined table data

Anyone know why this is happening?