1
我正在使用jquery手風琴來顯示帶有子項目的列表。 我有一個類別表和產品表。我想將這些分類和相應的產品提取到列表中。 在我的控制器我添加下面的代碼。jquery accordian列表子菜單項無法在cakephp中顯示數據庫中的值
$category=$this->Category->find('list',
array('fields'=>array('id','category_name')));
$this->set('category',$category);
$productlist=$this->Product->find('list',
array('fields'=>array('id','product_name','category_id')));
$this->set('productMenu',$productlist);
而且在我的名單,我增加值列表
<ul id="nav"><?php
foreach ($category as $key => $value)
{
?><li><a href="#"><?php echo $value; ?></a>
<ul class="sub">
<?php foreach ($productMenu as $key => $value)
{ ?>
<li><a href="#"><?php echo $value; ?></a>
<?php } ?>
</ul>
</li><?php
}
?></ul>
現在的類別顯示好,我didont得到邏輯添加屬於特定categry產品。如果有人知道這一點,請幫助我。 IAM stucking ..
還當我調試這個結果我得到的結果
debug($catgory)
array(
(int) 1 => 'Crowns And Bridges Non Metal',
(int) 2 => 'Crowns And Bridges Metal',
(int) 3 => 'Implants',
(int) 4 => 'Dentures'
)
debug($product)
array(
(int) 1 => array(
(int) 1 => 'Lava',
(int) 2 => 'ZR Crown'
),
(int) 2 => array(
(int) 3 => 'Porcelain fused to metal crowns'
),
(int) 3 => array(
(int) 4 => 'General Restorative',
(int) 5 => 'Customised Abutments',
(int) 6 => 'Avinent Implants'
),
(int) 4 => array(
(int) 7 => 'Partial Dentures',
(int) 8 => 'Complete Dentures:'
)
謝謝你的回答..我會ping你一次,我檢查這個結果 – SibinF
非常感謝。現在它的工作正常..我感謝你 – SibinF