<?php include_once("db_menu.php");
echo "SELECT `menu_ID`, `menu_name` FROM `menu` WHERE `menu_topid`=0 AND `menu_display` != 0 ORDER BY `menu_position` ASC";
$sql=mysql_query("SELECT `menu_ID`, `menu_name` FROM `menu` WHERE `menu_topid`=0 AND `menu_display` != 0 ORDER BY `menu_position` ASC") or die("Fehler".mysql_error());
$nav_array = array();
$i = 0;
while ($nav_data = mysql_fetch_array($sql)) {
$nav_array[$i] = array('menu_ID'=>$nav_data["menu_ID"], 'menu_name'=>$nav_data["menu_name"]);
$i++;
}
$nav_id = (int) $_GET["nav_id"];
if ($nav_id <= 0) {
$nav_id = $nav_array[0]['menu_ID'];
}
echo "SELECT * FROM `menu` WHERE `menu_ID` = $nav_id";
$sql=mysql_query("SELECT * FROM `menu` WHERE `menu_ID` = $nav_id") or die("Fehler".mysql_error());
$page_data = mysql_fetch_array($sql);
$page_id = $page_data["menu_page"];
$child_array = array();
$root_array = array();
//Die Stufe beginnt von unten zu zählen, statt von oben. Wird am Schluss umgerechnet
$invlevel = 1;
echo "SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $nav_id and `menu_display` != 0 ORDER BY `menu_position`";
$sql=mysql_query("SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $nav_id and `menu_display` != 0 ORDER BY `menu_position`") or die("Fehler".mysql_error());
$i = 0;
while ($subnav_data = mysql_fetch_array($sql)) {
$child_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
$i++;
}
//Die nächsthöhere TopID
$next_topid = $page_data["menu_topid"];
//Solange durchlaufen lassen bis obersten Navitationsteile erreicht sind (top_id == 0)
while (($next_topid != 0 || $next_topid != false)) {
if(empty($child_array[0]["menu_topid"])) {
$top_id = $nav_id;
} else {
$top_id = $child_array[0]["menu_topid"];
}
$invlevel++;
$i = 0; //Zähler in der Schlaufe
echo "SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $next_topid ORDER BY `menu_position` ASC";
$sql=mysql_query("SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $next_topid ORDER BY `menu_position` ASC") or die("Fehler".mysql_error());
//Die Tabelle auslesen
while($subnav_data = mysql_fetch_array($sql)) {
$root_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
if($root_array[$i]["menu_ID"] == $top_id) {
$root_array = array_merge($root_array, $child_array);
//Minus 1, weil es sonst einen Zwischenraum gibt. Z.B. $root_array[2], dann $root_array[4]
$i = count($root_array) - 1;
}
$i++;
}
$child_array = $root_array;
$root_array = array();
//Hier wird noch mit der alten $next_topid gerechnet. Die Topid vom höheren Menu wird gelesen
echo "SELECT `menu_topid` FROM `menu` WHERE `menu_ID` = $next_topid LIMIT 1";
$sql=mysql_query("SELECT `menu_topid` FROM `menu` WHERE `menu_ID` = $next_topid LIMIT 1") or die("Fehler".mysql_error());
$subnav_data = mysql_fetch_array($sql);
//Neues $next_topid
$next_topid = $subnav_data["menu_topid"];
}
$anzlevel = $invlevel;
$invlevel = 0;
$number = count($child_array);
//Die Umrechnunsschleife, die Levels werden neu gesetzt: Das Höchste jetzt das Tiefste und umgekehrt
for($i = 0; $i < $number; $i++) {
$invlevel = $child_array[$i]['level'];
$child_array[$i]['level'] = $anzlevel - $invlevel + 1;
}
//Die Subnav_array mit dem vollständigen child_array füllen
$subnav_array = $child_array;
?>
</div>
<div id="content">
<?php include_once("db_content.php");
echo "SELECT * FROM `content` WHERE `content_ID` = $page_id";
$sql=mysql_query("SELECT * FROM `content` WHERE `content_ID` = $page_id") or die("Fehler".mysql_error());
$data = mysql_fetch_array($sql);
$content_title = $data["content_title"];
$content_text = $data["content_text"];
if ($content_title == "" && $content_text == "") {
$content_title = "JClub-Noch kein Inhalt";
$content_text = "Keine Daten gefunden";
}
?>