0
我有foloowing控制器(supernavigationloggedin):查询与View传递笨
<?php
class Supernavigationloggedin extends CI_Controller {
function index(){
#get current session id
$currentSessionID = $this->session->userdata('session_id');
#get all the account row for the given sessionID
$data['info'] = $this->db->get_where('Client', array('session_id'=>$currentSessionID))->row();
#views
$this->load->view('supernavigationloggedin',$data);
}
}
?>
,并命名为下面的视图(supernavigationloggedin):
<div id="superNavigation">
<h5><strong>Welcome</strong>, <?php $info->fname; ?> <a href="#">Account Settings</a></h5>
<div class="clearL"> </div>
</div
>
它不断抛出在线错误:<h5><strong>Welcome</strong>, <?php echo $info['fname']; ?> <a href="#">Account
即消息:>>>Trying to get property of non-object
我试过:<?php echo $info['fname']; ?> <?php echo $info->fname; ?>
但似乎都没有工作。
感谢您的帖子。所以,在我看来,我输出<?php $ info ['fname']; ?>是吗? – CodeTalk
如果你使用我的答案的第一个查询,你使用'$ info-> fname',如果你使用seconth,你可以使用'$ info ['fname']'。我建议你在你的视图中使用'print_r($ info)'来查看它包含的内容。 –
但是这个$ info-> fname是否需要echo $ info-> fname? – CodeTalk