Welcome Guest, Not a member yet? Register   Sign In
sub-categories and sub-subcategories on a associative array with CI
#1

[eluser]MEM[/eluser]
After some long days,

I'm trying to create an associative array containing only sub-categories and sub-subcategories, from a self-reference table.

I'd like to have something like this:

[
SUBCATEGORY1 [
SUB_SUBCATEGORY1
SUB_SUBCATEGORY2
SUB_SUBCATEGORY3
]
SUBCATEGORY2
SUBCATEGORY3
]

I'm having troubles to get out an array like this from my model.
Now, my model looks like this:

Code:
function getSubCategorias($id_cat)
{
    $this->db->where('parent_id_cat', $id_cat);
            
    $this->db->where('activa_cat =', 1);
            
    $query=$this->db->get('categoria');
            
    if($query->num_rows()>0)
    {
        return $query->result();
    }
}

I'm retrieving the $id_cat because, I want to show each time, only the subcategories of a specific category. I mean, if the user is on page related with category 1, I only want to show subcategories and sub-subcategories of that main category 1.

What query should I have to get all subcategories and sub-subcategories of a specific category, in order to build the desired associative array?

Can I have your help on this... Sad

Always newbie,
Márcio


Messages In This Thread
sub-categories and sub-subcategories on a associative array with CI - by El Forum - 09-04-2009, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB