Codeigniter显示2个crud杂货餐桌到1桌

时间:2016-10-22 18:51:54

标签: php codeigniter grocery-crud

这是两张桌子。

我想把它变成1桌

enter image description here

我是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-&gt; load-&gt; view(&#39; golongan&#39;,$ output);杂货店   没出现,

     

//如果我删除了$ this-&gt;渲染(&#39; golongan&#39;,&#39; full_width&#39;);模板   没有出现

     

//如果我同时添加了两个,那么我希望将它变为1   表

视图&gt; golongan.php

&#13;
&#13;
<?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; ?>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:0)

如果要在同一视图中显示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; ?>

答案 1 :(得分:0)

Hy fahmi,试试这个:

&#13;
&#13;
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);
        }
&#13;
&#13;
&#13;

答案 2 :(得分:0)

类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();


    }

}