简体   繁体   中英

Codeigniter display 2 crud grocery table to 1 table

Here are two tables.

i want make it to 1 table

在此处输入图片说明

I am new with codeigniter and crud grocery, my Golongan display 2 table, i don't have idea to resolve it

controller>Golongan.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Golongan extends MY_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->database();
        $this->load->helper('url');
        $this->load->library('grocery_CRUD');
    }
    public function index()
    {
        $crud = new grocery_CRUD();
        $crud->set_table('golongan');
        $crud->columns('idgol', 'jabatan', 'fasilitas');

        $crud->unset_delete();
        $crud->unset_edit();
        $crud->unset_add();
        $output = $crud->render();

        $this->load->view('golongan',$output);
        $this->render('golongan','full_width'); // (full_width) it must for load template
        }
}

// if i deleted $this->load->view('golongan',$output); grocery crud not appear,

// if i deleted $this->render('golongan','full_width'); template not appear

//if i added both, there are 2 tables, i want make it into 1 table

view>golongan.php

 <?php foreach($css_files as $file): ?> <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" /> <?php endforeach; ?> <?php foreach($js_files as $file): ?> <script src="<?php echo $file; ?>"></script> <?php endforeach; ?> <?php echo $output; ?> 

if you want display 2 tables in the same view...pass each output object to the view

Controller

  $crud = new grocery_CRUD();
    $crud->set_table('Table2');
    $crud->columns('idgol', 'jabatan', 'fasilitas');

    $crud->unset_delete();
    $crud->unset_edit();
    $crud->unset_add();
    $data['output'] = $crud->render();

 $crud = new grocery_CRUD();
    $crud->set_table('Table_2');
    $data['output_2'] = $crud->render();

    $this->load->view('your_view',$data);     

in the view

       <?php 
foreach($output->css_files as $output->file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $output->file; ?>" />
<?php endforeach; ?>
<?php foreach($output->js_files as $output->file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>

<?php echo $output->output; ?>
<?php echo $output_2->output; ?>

Hy fahmi, try this :

 public function index() { $crud = new grocery_CRUD(); $crud->set_table('golongan'); $crud->columns('idgol', 'jabatan', 'fasilitas'); $crud->unset_delete(); $crud->unset_edit(); $crud->unset_add(); $output = $crud->render(); $view = 'golongan'; $this->outputview->output_admin($view, $output); } 

class Golongan extends MY_Controller {

function __construct()
{
    parent::__construct();
    $this->load->database();
    $this->load->helper('url');
    $this->load->library('grocery_CRUD');
}
public function index()
{
    $crud = new grocery_CRUD();
    $crud->set_table('golongan');
    $crud->columns('idgol', 'jabatan', 'fasilitas');

    $crud->unset_delete();
    $crud->unset_edit();
    $crud->unset_add();
    $output = $crud->render();


    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM