【发布时间】:2013-05-06 04:22:18
【问题描述】:
我正在尝试获取注册用户的名字和姓氏。 这是我模型中的 getfirstname , getlastname 函数
public function getf()
{
$email = $this->input->post('email');
$this->db->where('email', $this->input->post('email'));
$query = $this->db->get('users');
if($query->num_rows == 1)
{
$row = $query->row();
echo $row->fname;
}
}
public function getl()
{
$this->db->where('email', $this->input->post('email'));
$query = $this->db->get('users');
if($query->num_rows == 1)
{
$row = $query->row();
echo $row->lname;
}
}
在我的控制器中:
public function members()
{
if($this->session->userdata('is_logged_in'))
{
$data['fname'] = $this->getf();
$data['lname'] = $this->getl();
$this->load->view('members', $data);
}
else
{
redirect('main/restricted');
}
}
我在我的视图中回显 fname 和 lname 变量,它打印“数组”而不是实际的名字和姓氏
echo $fname;
echo $lname;
【问题讨论】:
标签: php mysql codeigniter