Jump to content

Undefined Table Data?


Jakebert

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.