Welcome Guest, Not a member yet? Register   Sign In
Display Nested categories
#13

[eluser]shailendra[/eluser]
Now I get the parent category with the code you gave, but I still don't get subcategory.I did some modification to the code you gave as the code you gave was not working for subcategory.

In view:
Code:
$categories = (array) $categories;
foreach($categories as $category)
{
    // echo $category->category_name;
    $category = (array) $category;
    echo $category['category_name'];
    $i=0;
    $category['sub_category'][$i] = (array) $category['sub_category'][$i];
    foreach($category['sub_category'][$i] as $lrow)
    {
        $lrow = (array) $lrow;
        echo $lrow['category_name'];
        $i++;
    }
}

I get following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: sub_category

Filename: views/category_view.php

Line Number: 9

A PHP Error was encountered

Severity: Notice

Message: Undefined index: category_name

Filename: views/category_view.php

Line Number: 7

----------------------------------------------------

If I do only this in view:

Code:
<?php
$categories = (array) $categories;
foreach($categories as $category)
{
    // echo $category->category_name;
    $category = (array) $category;
    echo $category['category_name'];
    /*$i=0;
    $category['sub_category'][$i] = (array) $category['sub_category'][$i];
    foreach($category['sub_category'][$i] as $lrow)
    {
        $lrow = (array) $lrow;
        echo $lrow['category_name'];
        $i++;
    }*/
}
?>

I get following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: category_name

Filename: views/category_view.php

Line Number: 7


Messages In This Thread
Display Nested categories - by El Forum - 07-10-2011, 10:06 PM
Display Nested categories - by El Forum - 07-14-2011, 04:11 AM
Display Nested categories - by El Forum - 07-14-2011, 04:20 AM
Display Nested categories - by El Forum - 07-15-2011, 12:18 AM
Display Nested categories - by El Forum - 07-15-2011, 02:00 AM
Display Nested categories - by El Forum - 07-17-2011, 11:31 PM
Display Nested categories - by El Forum - 07-17-2011, 11:39 PM
Display Nested categories - by El Forum - 07-18-2011, 03:19 AM
Display Nested categories - by El Forum - 07-18-2011, 05:51 AM
Display Nested categories - by El Forum - 07-18-2011, 09:47 AM
Display Nested categories - by El Forum - 07-18-2011, 11:20 PM
Display Nested categories - by El Forum - 07-18-2011, 11:24 PM
Display Nested categories - by El Forum - 07-19-2011, 01:30 AM
Display Nested categories - by El Forum - 07-20-2011, 09:25 PM
Display Nested categories - by El Forum - 07-20-2011, 11:06 PM
Display Nested categories - by El Forum - 07-21-2011, 03:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB