I have right following code for to set Parent-Child Array Structure like..
$refs = array();
$list = array();
while($QryRow_Category_sub = mysqli_fetch_assoc($QryResult_Category))
{
$thisref = &$refs[$QryRow_Category_sub['id']];
$thisref['parent_id'] = $QryRow_Category_sub['parent_id'];
$thisref['name'] = $QryRow_Category_sub['name'];
if ($QryRow_Category_sub['parent_id'] == 0) {
//echo &$thisref;
$list[$QryRow_Category_sub['id']] = &$thisref;
} else {
$refs[$QryRow_Category_sub['parent_id']]['children'][$QryRow_Category_sub['id']] = &$thisref;
}
}
And this is my Output
Television Cat - 1
Television Cat - 1 Sub Cat - 1
Television Cat - 1 Sub Cat - 2
Television Cat - 2
Television Cat - 2 Sub Cat - 1
Television Cat - 3
Television Cat - 3 Sub Cat - 1
Television Cat - 4
Television Cat - 4 Sub Cat - 1
Television Cat - 1 Sub Cat - 1
Television Cat - 1 Sub Cat - 2
Television Cat - 2 Sub Cat - 1
Television Cat - 3 Sub Cat - 1
Television Cat - 4 Sub Cat - 1
This my code and i got the result good, but i have one problem with this. But i want to remove the following code from the output
Television Cat - 1 Sub Cat - 1
Television Cat - 1 Sub Cat - 2
Television Cat - 2 Sub Cat - 1
Television Cat - 3 Sub Cat - 1
Television Cat - 4 Sub Cat - 1
This is the duplicate entry of sub-category.
Please give a solution. Thank You.