[eluser]ede196620[/eluser]
So i have functions view update and delete. Update and delete works as it suppose to but the view function dose not perform as it suppose to fore some reason it keeps trowing me these 2 errors
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: table
Filename: views/display_view.php
Line Number: 15
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: pagination
Filename: views/display_view.php
Line Number: 16
i cant figure out i looked at all of my code 100 times and cant find where i went wrong maybe some one can spot the mistake i am posting my view and the controller.
CONTROLLER
Code:
class Display extends CI_Controller {
private $limit = 5;
function __construct()
{
parent::__construct();
$this->load->library(array('table','form_validation'));
$this->load->model('display_model','',TRUE);
}
function index($offset = 0, $order_column = 'QID', $order_type = 'asc')
{
if (empty($offset)) $offset = 0;
if (empty($order_column)) $order_column = 'QID';
if (empty($order_type)) $order_type = 'asc';
//TODO: check for valid column
// load data
$querys = $this->display_model->get_paged_list($this->limit, $offset, $order_column, $order_type)->result();
// generate pagination
$this->load->library('pagination');
$config['base_url'] = site_url('display/index/');
$config['total_rows'] = $this->display_model->count_all();
$config['per_page'] = $this->limit;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
// generate table data
$this->load->library('table');
$this->table->set_empty(" ");
$new_order = ($order_type == 'asc' ? 'desc' : 'asc');
$this->table->set_heading(
'No',
anchor('display/index/'.$offset.'/Question/'.$new_order, 'Question'),
anchor('display/index/'.$offset.'/qA/'.$new_order, 'qA'),
anchor('display/index/'.$offset.'/qB/'.$new_order, 'qB'),
anchor('display/index/'.$offset.'/qC/'.$new_order, 'qC'),
'Actions'
);
$i = 0 + $offset;
foreach ($querys as $query){
$this->table->add_row(++$i,
$query->Question,
$query->qA,
$query->qB,
$query->qC,
anchor('display/view/'.$query->QID,'view',array('class'=>'view')).' '.
anchor('display/update/'.$query->QID,'update',array('class'=>'update')).' '.
anchor('display/delete/'.$query->QID,'delete',array('class'=>'delete','onclick'=>"return confirm('Are you sure you want to remove this Question?')"))
);
}
$data['table'] = $this->table->generate();
if ($this->uri->segment(3)=='delete_success')
$data['message'] = 'The Data was successfully deleted';
else if ($this->uri->segment(3)=='add_success')
$data['message'] = 'The Data has been successfully added';
else
$data['message'] = '';
// load view
$this->load->view('display_view', $data);
}
function view($id){
// set common properties
$data['title'] = 'Question Details';
$data['link_back'] = anchor('display/index/','List Of Questions',array('class'=>'back'));
// get Question details
$data['query'] = $this->display_model->get_by_id($id)->row();
// load view
$this->load->view('display_view', $data);
}
}
VIEW
Code:
<div class="content">
<h1>Add/Update/Delete </h1>
<div class="data"><?php echo $table; ?></div>
<div class="paging"><?php echo $pagination; ?></div>
<br />
<?php echo anchor('display/add/','Add new Question',array('class'=>'add')); ?>
<?php echo anchor('home/','Return to Dashboard'); ?>
</div>