well, Creating multi-level category system with PHP in not just a simple undertaking.
Many Developer usage different approach to manage this specific. They may possibly create 3 tables for initial level, subsequent level as well as 3rd level category (parent, sub category as well as sub sub cateogry).
The best method to acquire multi-level category using recursive function.
With this, let us build a database table i.e category. as shown below
.
Now time to get our hand dirty. Open your favorite editor, create a new file 'category.php' where we will list all category.
Create a new file i.e 'class.php' .Inside this we will create class and method to handle recursive function
also create a file to connect and select your database .i.e 'config.php'
If you searching a good Web Development Training center where you learn advance practical project based training ,visit us , You will become confident developing any project after our training completion .
Open class.php and write following code
Now we have created our class .Time to use this. So below in category.php , we have created a object from class 'cat' then access the method 'cat_list' as shown below
After , you can access category.php in your localhost like https://localhost/php/category.php
Add some category and sub category inside this by selecting category as parent.
It's ready to use php multi-level category .Follow Next tutorial to show products according to category selected .