我如何发布分类帖子标题?

时间:2015-09-12 12:30:15

标签: codeigniter-3

大家好我是一个新的codigniter我创建帖子并加入两个表我想在我的博客帖子中显示类别标题只有一个。但它不在我之后。在每个帖子中显示许多标题类别。我的代码:

COntroller:
    function index(){
        $this->home();
    }
    function home(){
        $this->load->view('header_view');
        $this->load->view('slide_view');
        $this->load->view('crumb_view');
        $this->load->view('footer_view');
    }

    function menu(){
        $this->load->model('tinjeat_md');
        $data["menu_pro"] = $this->tinjeat_md->menu_get();
        $this->load->view('header_view');
        $this->load->view('crumb_view');
        $this->load->view('menu_view',$data);
        $this->load->view('footer_view');
    }
}
Model:
class Tinjeat_md extends CI_Model{
    function __construct(){
        parent::__construct();
    }
    function menu_get(){
        $this->db->select('*');
        $this->db->from('menu','categories_menu');
        $this->db->join('categories_menu','menu.cate_id = categories_menu.id','left'); 
        $query = $this->db->get();
        return $query->result();    }
}
View:
<div class="menu">
<?php foreach ($menu_pro as $value): ?>
    <p class="title_cate">
        <?php echo $value->cate_name_menu; ?>
    </p>
<div class="menu_image">
<?php
echo img(array(
    'src'=>'./images/'.$value->image,
    'width'=>'220px',
    'height'=>'150px'
    ));
?>
</div>
<div class="menu_description">
    <h3><?php echo $value->title; ?></h3>
    <p><?php echo $value->description; ?></p>
    <p>Prices:<?php echo $value->prices; ?></p>
</div>
<?php endforeach; ?>
</div>

My database:
categories_menu
-id
-cate_menu_name

   menu
    -id_menu
    -title
    -image
    -description
    -prices
    -cate_id

请帮助我..

0 个答案:

没有答案