我的控制器是
function loginProcess()
{
$this->db->select('moduleId');
$this->db->from('roleaccess');
$this->db->where('userId',$session_data['userId']);
$query=$this->db->get();
$access=$query->row_array();
$variable=implode(",",$access);
$query = $this->db->query("SELECT moduleName,moduleUrl FROM module where moduleId in($variable)");
$resultdata['results'] = $query->result_array();
$responce=$tst+$resultdata;
$this->load->view('admin/users1',$responce);
}
function user()
{
//set table id in table open tag
$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable" style="border-collapse: collapse; ">' );
$this->table->set_template($tmpl);
$this->table->set_heading('Id','Email','UserName','View','Delete');
$this->load->view('subscriber_view');
}
在我看来,subscriber_view包含users1视图,如下所示
<?php
include("admin/users1.php");
?>
但它显示未定义的变量结果error.how我在所有其他视图中包含include(&#34; admin / users1.php&#34;)。请帮助我
答案 0 :(得分:0)
function user()
{
//set table id in table open tag
$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable" style="border-collapse: collapse; ">' );
$this->table->set_template($tmpl);
$this->table->set_heading('Id','Email','UserName','View','Delete');
$this->loginProcess();
$this->load->view('subscriber_view');
}
检查一下......你可以添加以前的控制器,它使用数据库中的数据调用标头,它也可以在这个控制器上工作:)
答案 1 :(得分:0)
您可以将文件包含为
function loginProcess()
{
$this->db->select('moduleId');
$this->db->from('roleaccess');
$this->db->where('userId',$session_data['userId']);
$query=$this->db->get();
$access=$query->row_array();
$variable=implode(",",$access);
$query = $this->db->query("SELECT moduleName,moduleUrl FROM module where moduleId in($variable)");
$resultdata['results'] = $query->result_array();
$responce=$tst+$resultdata;
// loading header before page
$this->load->view('admin/header');
$this->load->view('admin/users1',$responce);
}
function user()
{
//set table id in table open tag
$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable" style="border-collapse: collapse; ">' );
$this->table->set_template($tmpl);
$this->table->set_heading('Id','Email','UserName','View','Delete');
//header
$this->load->view('header');
$this->load->view('subscriber_view');
}
或在所有视图文件的顶部写下面的代码
<?php
$this->load->view('header');
?>