Welcome Guest, Not a member yet? Register   Sign In
Pagination and table error.
#1

[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">&lt;?php echo $table; ?&gt;</div>
            
              
  <div class="paging">&lt;?php echo $pagination; ?&gt;</div>

  <br />
  &lt;?php echo anchor('display/add/','Add new Question',array('class'=>'add')); ?&gt;
                &lt;?php echo anchor('home/','Return to Dashboard'); ?&gt;
                
</div>


Messages In This Thread
Pagination and table error. - by El Forum - 03-18-2013, 01:08 AM
Pagination and table error. - by El Forum - 03-18-2013, 01:09 AM
Pagination and table error. - by El Forum - 03-18-2013, 02:35 AM
Pagination and table error. - by El Forum - 03-18-2013, 03:14 AM
Pagination and table error. - by El Forum - 03-18-2013, 03:29 AM
Pagination and table error. - by El Forum - 03-18-2013, 03:49 AM
Pagination and table error. - by El Forum - 03-18-2013, 03:57 AM
Pagination and table error. - by El Forum - 03-18-2013, 04:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB