DB から動的な順不同リストが必要です
<div class="box">
<h2>Auswahl</h2>
<div class="auswahl">
<ul>
<li>
<a href="#">Kat a</a>
<ul class="submenuAuswahl">
<li><a href="#">a</a></li>
<li><a href="#">b</a></li>
<li><a href="#">c</a></li>
<li><a href="a">d</a></li>
<li><a href="#">e</a></li>
</ul>
</li>
<li>
<a href="#">Kat b</a>
<ul class="submenuAuswahl">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
</ul>
</li>
<li>
<a href="#">Kat c</a>
<ul class="submenuAuswahl">
<li><a href="#">I</a></li>
<li><a href="#">II</a></li>
<li><a href="#">III</a></li>
<li><a href="#">IV</a></li>
</ul>
</li>
</ul>
</div>
</div>
DB から 3 つのテーブルを選択し、array_merge
$data = array_merge( $z, $s, $k ); を作成します。
Array
(
[0] => Array
(
[id] => 1
[name] => a
)
[1] => Array
(
[id] => 2
[name] => b
)
[2] => Array
(
[id] => 3
[name] => c
)
[3] => Array
(
[id] => 1
[name] => 1
)
[4] => Array
(
[id] => 2
[name] => 1
)
[5] => Array
(
[id] => 1
[name] => I
)
[6] => Array
(
[id] => 2
[name] => II
)
[7] => Array
(
[id] => 3
[name] => III
)
)
2番目の配列にはカテゴワールがあります
Array
(
[id_a] => kat a
[id_b] => kat b
[id_c => kat c
)
両方の配列から、リスト構造を作成するために到着しません
$nav = new navigation($myDataArray);
$nav->createMenu($myCategoryArray);
<?php
class navigation {
private $menu = array();
private $data = array();
public function __construct($d){
$this->data = $d;
}
public function createMenu($aus){
$this->menu .= '<div class="box">';
$this->menu .='<h2>Auswahl</h2>';
$this->menu .='<ul><li>';
$key = '';
foreach($aus as $k => $v){
if($key != $k){
$this->menu .='<a href="#">'.$k.'</a>';
$this->createList($k);
}
$key = $k;
}
$this->menu .='</ul></li>';
}
public function createList($key){
$this->menu .= "<ul>";
foreach($this->data as $list => $in){
foreach($in as $k => $v){
$this->menu .= '<li class="hidden">'. $k .'</li><li><a href="#">'.$v.'</a></li>';
}
$this->menu .= "</ul>";
}
}
public function getMenu(){
return $this->menu;
}
public function getData()
{
return $this->data;
}
}