[英]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.