我有三個表標準化,分類清單和代碼點火器
文章
類別
和關係表articles_categories
該表是我存放我這樣使用正常化關係features.Like這
我能夠做的選擇,插入,更新,刪除。這裏是我以前的問題 Insert , Update , Delete -> Normalization & Code Igniter Saving articles and related categories according to normalization
什麼我想現在實現的是我試圖通過類來創建文章的列表。像這樣
Category Name
- article relating to that category
- article relating to that category
- article relating to that category
- article relating to that category
這是我的控制器
function category($id)
{
$data['title'] = "View by category";
$data['articles_categories']=$this->articles_categories_model->get_by_id($id);
$data['articles']=$this->articles_model->get();
$data['category_id']=$id;
$data['categories_list']=$this->categories_model->get();
$this->load->view('articles_pages/category',$data);
}
我的觀點
<?php
//$category_id;
foreach($articles as $a)
{
foreach($articles_categories as $ac)
{
if($ac['categories_id']==$category_id && $a['id']==$ac['articles_id'])
{
echo $a['title'];
}
}
}
?>
我不能讓慾望的結果。請幫幫我。謝謝
在同一頁面上是否顯示多個類別? – Jeemusu
單個類別 - >代表該類別的項目 –