Product Plan ProductPlan
id |name id |name id | product_id | plan_id
1 aplha 1 a 1 1 2
2 bravo 2 b 2 4 c
3 charlie 4 c
4 delta
我想打印計劃名稱對相關產品,像
查看,我想
alpha | delta |
a c
b
,但它顯示我像,
alpha | bravo | charlie |delta
a
b
c
這是我的控制器代碼
$p_plan = $this->ProductPlan->find('all',array(
'conditions'=>array(
'ProductPlan.product_id'=>'Product.product_id'
)
)
);
$this->set('p_plan', $p_plan);
這是我的看法代碼,
<table>
<thead>
<tr>
<?php foreach ($p as $ps){?>
<th>
<?php echo __l($ps['Product']['name']);?>
</th>
<?php }?>
</tr>
</thead>
<tbody>
<?php foreach ($p as $p1){
foreach($p1['Plan'] as $plan){
debug($plan);
?>
<tr>
<td>
<?php echo __l($plan['name']);?>
</td>
</tr>
<?php }
}?>
</tbody>
什麼是錯的,我的看法?如果一些身體幫我,我會很thaksful他。提前致謝。
請標記您正在使用的cakephp的唯一版本。 – Rikesh 2013-02-18 13:33:23