Jakebert Posted November 10, 2009 Share Posted November 10, 2009 OK, here's the problemo: Controller: <?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: <?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: <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 Read Undefined table data Anyone know why this is happening? Quote Link to comment https://forums.phpfreaks.com/topic/181012-undefined-table-data/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.