2016-11-26 80 views
3
function create() 
{ 
    $data['headline'] =" "; 
    $this->load->module('site_security'); 
    $this->site_security->_make_sure_is_admin(); 

    $update_id = $this->uri->segment(3); 

    if(!is_numeric($update_id)) 
    { 
     $data['headline'] = "Add New Product"; 
     //$data['headline'] = print_r($update_id)."if"; 
    } 

    else 
    { 
     $data['headine'] = "Update Product Details"; 
     //$data['headline'] = print_r($update_id)."else"; 
    } 

    $data['view_module'] = "store_products"; //passing module name 
    $data['view_file'] = "create"; //passing method name 
    $this->load->module('templates'); // loads the template module 
    $this->templates->admin($data); //calls the template controller method admin which loads the admin view 

} 

我正在传递标题文本,以根据url中第三个第三段的内容在视图中更改标题。第一个if语句完美地设置标题,但它不会进入else语句,并给我错误,因为$ headline在视图中未定义。奇怪的是,如果我使用评论print_r语句一切正常,它会显示在视图中。未将PHP codeigniter变量传递给视图

我认为它必须是行$ data ['headine'] =“更新产品详细信息”;在别的,但我不知道为什么。

回答

0

在你else语句,

else 
{ 
    $data['headine'] = "Update Product Details"; 
} 

您在这里有一个错字。将headine更改为headline