im dealing with encapsulated categories here. I want to resolve them until i reached the top layer by recursive function:
function resolve_kat($kat_id){
...credentials here...
$db = new mysqli($host_name, $user_name, $password, $database, NULL, $socket);
$sql_kat = "SELECT * FROM categories WHERE category=".$kat_id;
$kat_res = $db->query($sql_kat);
$kat = $kat_res->fetch_assoc();
if($kat['upppercategory']==0){
return $kat['category'];
}
else {
resolve_kat($kat['upppercategory']);
}
$kat_res->close();
}
$passtome = resolve_kat(927);
echo $passtome;
It works fine with echo
, but i want to pass the value to an other function.
What did i wrong?