Table: category
table structure
id
label
parent
example data
id - label - parent
1 - Apparel - 0
2 - Technology - 0
3 - Travel - 0
4 - shirts - 1
For above table I have two links
- First link display category with no parent (e.g. Apparel, Technology, Travel )
- Second link display subcategory with parent (e.g. shirts (parent - Apparel) )
How to display category and its subcategory if any link is clicked.
e.g.
if first link is clicked i.e. Apparel => display - Apparel - shirts
if second link, i.e. subcategory, is clicked i.e. shirts => display - Apparel - shirts