问题描述
我是Codeigniter的新手,我想显示从数据库中获取的我的应用博客文章的动态标题。我尝试了下面的代码,但我不断收到“未定义的变量错误”。
下面是控制器
function blogpost(){
$entry_slug = $this->uri->segment(2);
$config['total_rows'] = $this->Client_model->get_post_count();
$config['per_page'] = 5;
$data['queries'] = $this->Client_model->get_all_post($config['per_page']);
$result = $this->Client_model->get_post($entry_slug,$entry_name);
$data['title'] = $result['entry_name'];
$data['post']= $this->Client_model->get_post($entry_slug,$entry_name);
$this->load->view('templates/headerss',$data);
$this->load->view('pages/blogpost');
$this->load->view('templates/footerss');
}
模型是
function get_post($entry_slug,$entry_name){
$this->db->select();
$this->db->from('entry');
$this->db->where('entry_slug',$entry_slug);
$post = $this->db->get();
return $post->result_array(); }
我的观点是
<title><?php if (!empty($title)) echo $title;?></title>
请帮帮我,我已经坚持了好几天。我确实需要在单击每个博客帖子时从数据库表中更改标题(列“ entry_name”)。谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)