Thanks for the replies guys.
I have tried to get that done using this code.
I am using this class
$sql = mysql_query("select * from testcategories where parent_id=0 order by id asc ");
while($rs = mysql_fetch_array($sql))
{
echo "<B>-".$name = $rs['catname']."</b><br>";
$id = $rs['id'];
$data.= $this->GetSubCat($id);
echo $data;
}
var $dash = 0;
function GetSubCat($pid)
{
$this->dash++;
$subsql = "select * from testcategories where parent_id=".$pid;
$rs = mysql_query($subsql);
for($i=0;$i<=$this->dash;$i++)
{
$DashDisp .= "-";
}
while($res = mysql_fetch_array($rs))
{
echo "<br>".$DashDisp.$name= $res['catname']."<br>";
$id = $res['id'];
$dataSub .= $this->GetSubCat($id);
}
$this->dash = 0;
return $dataSub;
}
But still it is not showing properly like a tree.