I use it in the Top 5 new added row.
Please feel free to reuse it and tell me if you do.
Bests.
Code: Select all
/*
* Function which returns the current tree of the $num category:
* example: Top Cat -> Sub Cat -> SubSubCat
*/
function get_category_tree($num)
{
global $db;
$cattable=NULL;
$seperator=" -> ";
$strreturn="";
$i=0;
while($i<strlen($num))
{
$i=$i+3;
$cattable[]=substr($num,0,$i);
}
foreach($cattable as $value){
$query = "SELECT ".$sqltblpre."faqrubrik.titel FROM ".$sqltblpre."faqrubrik WHERE rubrik = '".$value."'";
$result = $db->query($query);
if ($db->num_rows($result) == 1) {
$row = $db->fetch_object($result);
$strreturn.=makeShorterText($row->titel,8).$seperator;
}
}
//Last separator is deleted
$strreturn=substr($strreturn,0 ,strlen($strreturn)-strlen($seperator));
return $strreturn;
}