I'm trying to query the db with the following query in the model:
function showSpecific(){
$all = $this->session->all_userdata();
$name = $all['u_name'];
$id = $this->db
->select('u_id')
->from('users')
->where('u_name', $name)
->get()
->row();
$id = $id->u_id;
$data = $this->db->query("SELECT messages.m_id, messages.post_id, messages.m_betreff, messages.an_user, messages.von_user, messages.m_time, users.u_id, users.u_name, posts.p_titel, users.u_id, messages.m_content
FROM messages
INNER JOIN users
ON messages.von_user=users.u_id
INNER JOIN posts
ON messages.post_id=posts.post_id
WHERE messages.an_user='$id'
ORDER BY messages.m_time DESC");
return $data;
}
But when I try to output the result in the view:
<?php foreach ($query->result() as $row)
{
echo '<tr><td>';
echo anchor('users/showUser/'.$row->u_id, $row->u_name);
echo '</td><td>';
echo $row->m_betreff;
echo '</td><td>';
echo $row->m_content;
echo '</td><td>';
echo anchor('posts/showSpecific/'.$row->post_id, $row->p_titel);
echo '</td><td>';
echo $row->m_time;
echo '</td></tr>';
}
?>
Only the m_content gets this error: Why is it the only one? And how do I solve this?
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$m_content
Filename: views/specific_message.php
Line Number: 48
Here is my Controller:
function showSpecific(){
$this->load->model('messages_model');
$data['query'] = $this->messages_model->getMessages();
$data['main_content'] = 'specific_message';
$this->load->view('includes/login_template', $data);
}
Thanks a lot!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…