S
shiva0101 m
Guest
Hi,
I have a table in which 3 fields are ther. category_id, category_name, parent_id
sample input
1 cat1 0
2 cat2 1
3 cat3 2
getPath(3) should get:
cat1/cat2/cat3
i tried to write the function but, its not returning anything,
function getPath($id)
{
$get_path_det = mysql_query("SELECT * FROM categories WHERE category_id='$id'");
$get_path_ret = mysql_fetch_assoc($get_path_det);
$category_id = $get_path_ret['category_id'];
$category_name = $get_path_ret['category_name'].'/'.;
$parent_id = $get_path_ret['parent_id'];
if($parent_id != 0)
getPath($parent_id);
else
return $category_name;
}
can someone tell me what's wrong with the above function
Thanks
I have a table in which 3 fields are ther. category_id, category_name, parent_id
sample input
1 cat1 0
2 cat2 1
3 cat3 2
getPath(3) should get:
cat1/cat2/cat3
i tried to write the function but, its not returning anything,
function getPath($id)
{
$get_path_det = mysql_query("SELECT * FROM categories WHERE category_id='$id'");
$get_path_ret = mysql_fetch_assoc($get_path_det);
$category_id = $get_path_ret['category_id'];
$category_name = $get_path_ret['category_name'].'/'.;
$parent_id = $get_path_ret['parent_id'];
if($parent_id != 0)
getPath($parent_id);
else
return $category_name;
}
can someone tell me what's wrong with the above function
Thanks