Welcome Guest, Not a member yet? Register   Sign In
Categories and Sub Categories
#12

[eluser]bluepicaso[/eluser]
thnx morcegon...
your post helped
here is my code for model
get.php
Code:
function getParentCats()

    {

        $this->db->select('*');

        $this->db->from('category');

        $this->db->where('parent_cat', 0);

        

        $query = $this->db->get()->result_array();

        foreach($query as $row)

        {

            $data[] = $row;

        }

        return $data;

        $this->db->close();

    }



    function getSubCats($parentid)

    {

        $this->db->select('*');

        $this->db->from('category');

        $this->db->where('parent_cat', $parentid);

        $query = $this->db->get()->result_array();

        foreach($query as $row)

        {

            $data[] = $row;

        }

        return $data;

        $this->db->close();

    }

code for my controller

Code:
function whatever()

    {

        $this->load->model('get');

        $dbCategories = $this->get->getParentCats();

        foreach ($dbCategories as $dbCategory)

        {

            

            $categories[$dbCategory['cat_name']]['subcategories'] = @$this->get->getSubCats($dbCategory['cat_id']);

        }

        ?>

        <pre>

        &lt;?

        print_r($categories);

        ?&gt;

        </pre>

        &lt;?

    }

My purpose solves here. I want to delete all packages and sub categories


Messages In This Thread
Categories and Sub Categories - by El Forum - 09-15-2007, 05:30 PM
Categories and Sub Categories - by El Forum - 09-15-2007, 07:13 PM
Categories and Sub Categories - by El Forum - 09-15-2007, 08:31 PM
Categories and Sub Categories - by El Forum - 09-15-2007, 09:30 PM
Categories and Sub Categories - by El Forum - 09-21-2007, 09:59 AM
Categories and Sub Categories - by El Forum - 09-21-2007, 05:19 PM
Categories and Sub Categories - by El Forum - 11-12-2007, 10:25 PM
Categories and Sub Categories - by El Forum - 11-13-2007, 01:51 AM
Categories and Sub Categories - by El Forum - 01-14-2009, 10:13 AM
Categories and Sub Categories - by El Forum - 01-15-2009, 09:54 AM
Categories and Sub Categories - by El Forum - 04-29-2010, 07:51 AM
Categories and Sub Categories - by El Forum - 06-16-2010, 06:04 AM
Categories and Sub Categories - by El Forum - 06-17-2010, 04:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB