function navigation($katid)
{
$retVal = false;
$res1 = mysql_query("
SELECT
kat_id,
kat_bez,
eb
FROM
bm_kategorien
WHERE
bm_kategorien.kat_id1 = ".$katid."
");
if( mysql_num_rows($res1) ) {
$retVal = '<ul>';
while( $erg1 = mysql_fetch_assoc($res1) ) {
if( zaehlen($erg1["kat_id"]) ==0 ) {
continue;
}
$retVal .= '<li class=\"sub\">';
if( ($buffer = navigation($erg1['kat_id'])) === false ) {
$retVal .= '<a href="'.htmlspecialchars($_SERVER['PHP_SELF'].'?id='.$erg1['kat_id'].'&wert='.zaehlen($erg1['kat_id'])).'">'.htmlspecialchars($erg1['kat_bez']).' ('.zaehlen($erg1['kat_id']).')';
$retVal .= '<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><a href="'.htmlspecialchars($_SERVER['PHP_SELF'].'?id='.$erg1['kat_id'].'&wert='.zaehlen($erg1['kat_id'])).'">'.htmlspecialchars($erg1['kat_bez']).' ('.zaehlen($erg1['kat_id']).')<table><tr><td><![endif]-->';
} else {
$retVal .= '<a class="hide">'.htmlspecialchars($erg1['kat_bez']).' ('.zaehlen($erg1['kat_id']).')';
$retVal .= '<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><a href="'.htmlspecialchars($_SERVER['PHP_SELF'].'?id='.$erg1['kat_id'].'&wert='.zaehlen($erg1['kat_id'])).'">'.htmlspecialchars($erg1['kat_bez']).' ('.zaehlen($erg1['kat_id']).') <table><tr><td><![endif]-->';
$retVal .= $buffer;
$retVal .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
}
$retVal .= '</li>';
}
$retVal .= '</ul>';
}
mysql_free_result($res1);
return $retVal;
}
echo navigation(0);
function zaehlen($katid)
{
list ($anzahl) = mysql_fetch_row(mysql_query("
SELECT
count(*)
FROM
bm_kat
WHERE
bm_kat = ".$katid."
"));
$res1 = mysql_query("
SELECT
kat_id
FROM
bm_kategorien
WHERE
bm_kategorien.kat_id1 = ".$katid."
");
while($erg1 = mysql_fetch_assoc($res1))
$anzahl += zaehlen($erg1["kat_id"]);
mysql_free_result($res1);
return $anzahl;
}
echo "</ul>";
echo "</div>";