私はサイトに挿入された場所の製品メニューを作成しています。障害が発生しただけで、私はそれを修正する方法を見つけることができません。PHPとMYSQLを使った動的な動的製品メニュー
マイコード:
public function getProductList($type = NULL, $brand = NULL){
if(empty($type) and empty($brand)){
$types = $this->productmodel->getTypeList(); // Category as arraylist
$brands = $this->productmodel->getBrandList(); // Brandnames as arraylist
$products = $this->productmodel->getProduct(); // All available products
$menu = array();
foreach($products as $product) {
[$product['brand_id']]
$menu[$product['type_id']] = array (
'type' => array(
'url' => base_url('index.php/productcontroller/getProductList/'.$product['type_id']),
'type_name' => $types[$product['type_id']]
)
);
// Brands
$menu[$product['type_id']]['brands'] = array (
$product['brand_id']['brand'] => array(
'url' => base_url('index.php/productcontroller/getProductList/'.$product['type_id'].'/'.$product['brand_id']),
'brand_name' => $brands[$product['brand_id']]
)
);
}
return $menu;
}
Futherは、次のように説明し
私は、データベース内の3つのテーブルを持っています。 1.Type:with:type.idとtype_name、 2.Brand:with:brand.idとbrand_type、 3.Products - with:上記のテーブルのIDを持つ製品に関するすべての情報。
最新の製品のみが表示されます。だから他のすべてのブランド名は上書きされます。私は重複しているブランド名を上書きしたかったので、そのブランド名( 'id']を使用します)どうすればこの仕事をすることができますか?私はCodeigniterを使用します。あなたの時間と労力のため
おかげで、あなたは各反復で$menu[$type_id]['brands']
配列を上書きしている
挨拶
注: のみ最後BRAND_NAMEが表示されます。タイプが正しく機能しています。 – Loed