我的控制器是
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");
?>
但是它显示了未定义的变量结果错误。如何在所有其他视图中包含include("admin/users1.php")。请帮助我
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');
}
看看这个。。。您可以添加以前的控制器,该控制器使用数据库中的数据调用标头,它也可以在该控制器上工作:)
您可以将文件包括为
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');
?>