0
我有兩個表'類別'和'組織'。根據我的觀點,我想列出所有在各類別表下工作的組織。我所做的是如下圖所示:得到分類的結果採取參數內循環codeigniter
*這裏是我的控制器:*
這裏的模型:
function get_categorised_organization() function get_categorised_organization() {
$category = $this->category_model->get_all_category();
$i = 0;
foreach ($category as $c):
$sql = "SELECT * FROM ss_organization where org_working_area='$c->category_name'";
$query = $this->db->query($sql);
$result[] = $query->result();
endforeach;
return $result;
} {
$category = $this->category_model->get_all_category();
$i = 0;
foreach ($category as $c):
$sql = "SELECT * FROM ss_organization where org_working_area='$c->category_name'";
$query = $this->db->query($sql);
$result[] = $query->result();
endforeach;
return $result;
}
和這裏的景色
<?php foreach($category as $c): ?>
<div class="categorybox">
<h2><?php echo $c->category_name;?></h2><hr>
<ul>
<?php //print_r($organization); die();?>
<?php foreach($organization as $o):?>
<?php foreach($o as $p): ?>
<li><a href="<?php echo base_url();?>index.php/home_controller/organization_detail/<?php echo $p->org_id;?>"><?php echo $p->org_name;?></a></li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach;?>
現在是什麼我得到相同的組織在不同類別的..我怎樣才能在相應類別的工作各自組織
你試過'加入'嗎? –
不,我沒有。我嘗試了其他一切。你能給我概念我怎麼可以得到使用連接的結果? – bhetus