CodeIgniter Forums
codeigniter get category and subcategory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: codeigniter get category and subcategory (/thread-68418.html)



codeigniter get category and subcategory - timelancer - 07-08-2017

Hello Im new in code igniter 

i want to display category and subcat of this category


when i enter url 

http://localhost/ci/index.php/category/1


[Image: 3r-GJelHTi2__qj0HnRhvg.png]

sorry for my bad english


RE: codeigniter get category and subcategory - Wouter60 - 07-08-2017

You will need a route in application/config/routes.php. E.g.:
PHP Code:
$route['category/(:any)'] = 'category/view/$1'

Create a controller named Category.php
Create a method inside it named view, which accepts the category_id as parameter:
PHP Code:
public function view($category)
{
 
 //collect category and subcategories from your database, see documentation about the Query Builder.
 
 //display the data in a view you load, see documentation about loading views


The tutorial about the News section could give you a good start.


RE: codeigniter get category and subcategory - InsiteFX - 07-08-2017

I think this is what your looking for.

Article:

Download Code: