[英]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 我是Codeigniter和Crud杂货店的新手,我的Golongan展示2桌,我不知道如何解决
controller>Golongan.php 控制器> 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); //如果我删除了$ this-> load-> view('golongan',$ output); grocery crud not appear, 没有出现杂货杂货,
// if i deleted $this->render('golongan','full_width'); //如果我删除了$ this-> render('golongan','full_width'); template not appear 模板未出现
//if i added both, there are 2 tables, i want make it into 1 table //如果我同时添加了两个表,我希望将其放入1个表中
view>golongan.php 查看> 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 如果要在同一视图中显示2个表...将每个输出对象传递给该视图
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 { Golongan类扩展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();
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.