[英]Codeigniter display 2 crud grocery table to 1 table
这是两个表。
我想做成一张桌子
我是Codeigniter和Crud杂货店的新手,我的Golongan展示2桌,我不知道如何解决
控制器> 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
}
}
//如果我删除了$ this-> load-> view('golongan',$ output); 没有出现杂货杂货,
//如果我删除了$ this-> render('golongan','full_width'); 模板未出现
//如果我同时添加了两个表,我希望将其放入1个表中
查看> 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; ?>
如果要在同一视图中显示2个表...将每个输出对象传递给该视图
控制者
$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);
在视图中
<?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; ?>
你好,试试这个:
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); }
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.