⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Grocery CRUD: can't display table's data



Noel Calonia
  • profile picture
  • Member

Posted 14 July 2015 - 13:46 PM

hello groceryCRUD community, i have a problem with my code since i am new to this CI framework. I try to connect with my existing database in my project to the said framework and follow some basic tutorial to display the said table data but it print with blank. Any help will be much appreciated, thanks!  :)

 

My codes: 

 

controller/main.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Main extends CI_Controller {
 
    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->library('grocery_CRUD');
 
    }
 
    public function index() {
        $this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }

    public function residents() {
        $crud = new grocery_CRUD();

        $crud->set_subject('Resident');
        $crud->set_theme('datatables');
        $crud->set_table('resident');
        $crud->columns('First Name','Middle Name','Last Name','Gender','Birthdate','Age','Citizenship','Occupation','Status','Purok','Residential Address','Permanent Address','Email','Telephone #','Cellphone #');
        $crud->fields('name','mname','lname','gender','bday','age','citizenship','occupation','status','purok','resAddress','perAddress','email','telNum','cpNum');
        $crud->set_primary_key('resident_id','resident');
        $crud->set_relation('resident_id','resident','resident_id');

        $crud->display_as('resident_id','ID');
        $crud->display_as('name','First Name');
        $crud->display_as('mname','Middle Name');
        $crud->display_as('lname','Last Name');
        $crud->display_as('gender','Gender');
        $crud->display_as('bday','Birthdate');
        $crud->display_as('age','Age');
        $crud->display_as('citizenship','Citizenship');
        $crud->display_as('occupation','Occupation');
        $crud->display_as('status','Status');
        $crud->display_as('purok','Purok');
        $crud->display_as('resAddress','Residential Address');
        $crud->display_as('perAddress','Permanent Address');
        $crud->display_as('email','Email Address');
        $crud->display_as('telNum','Tel. #');
        $crud->display_as('cpNum','Cellphone #');

        $output = $crud->render();
 
        $this->_example_output($output);
    }

    function _example_output($output = null) {
        $this->load->view('our_template.php',$output);  
    }
}

Output:

 

[attachment=976:Untitled.jpg]