i have a mysql table which is

categoryid
categoryname
parentid

now the senario is that i want to grab all categoryid of a parentid ...

like

if i put parent id = 12

so that parent id has now become root id and it should get all the sub sub categories of that parent id ... thanks for ur help in advance

found the solution here nice site

1.
function showlist($parent, &$catlistids="") {
2.
$result = mysql_query("SELECT ID FROM categorie WHERE sublevelID='$parent'");
3.
while ($line = mysql_fetch_array($result)) {
4.
if($catlistids!=""){ $catlistids .= ", "; }
5.
$catlistids .= $line["ID"];
6.
showlist($line["ID"], &$catlistids);
7.
}
8.
return $catlistids;
9.
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.