function createPath($id, $category_tbl, $path) {
$s = "SELECT * FROM ".$category_tbl." WHERE ID = $id";
$r = mysql_query($s);
$row = mysql_fetch_array($r);
if($row['PARENT_ID'] == 0) {
$path .=$row['TITLE'].'-';
}
else {
$path .='-'.$row['TITLE'];
createPath($row['PARENT_ID'],$category_tbl, $path);
}
return $path;
}
It is a recursive function that must generate breadcrumbs. I cannot get it to work properly, it only returns the last TITLE.
the sql table is something like ID, TITLE, PARENT_ID
a PARENT_ID = 0 means the category has no parent,
for any other PARENT_ID, go to that ID, get it's title and add it to the $path
variable
I need help to make this work. Alternatives are also welcomed.