Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------------
- view
- ----------------------------------------------------------------------------------------
- <div class="columnFull last">
- <?php $categories = $this->categoryModel->getCategories(); ?>
- <?php foreach ($categories as $category):?>
- <!-- get all categories with no parent category from the database and loop through them -->
- <div class="blockHead">
- <?php echo $category->cat_name ?>
- <!-- echo the categorys name -->
- </div>
- <div class="blockBody">
- <?php $sub_categories = $this->categoryModel->getCategories($category->cat_id); ?>
- <?php foreach ($sub_categories as $sub_categories):?>
- <!-- get all categories with the currently looping category as their parent category from the database -->
- <div class="blockHead top20">
- <?php echo $sub_categories->cat_name ?>
- <!-- echo the sub-categorys name -->
- </div>
- <?php endforeach;?>
- </div>
- <?php endforeach;?>
- </div>
- ------------------------------------------------------------------------------------------------------
- categoryModel
- ------------------------------------------------------------------------------------------------------
- <?php
- function getCategories($category = 0)
- {
- $query = $this->db->get_where('categories', array('cat_parent' => $category));
- return $query->result();
- }
- ?>
Add Comment
Please, Sign In to add comment