My categories table design is as follows
I have three levels of category
- parent
- child
- sub child
How to display them in the following manner ?
(SELECT * FROM categories) : i get the following array as below
Array
(
[0] => stdClass Object
(
[category_id] => 1
[category_slug] =>
[category_glyphicon] => live glypicon
[category_name] => Live
[is_parent] => 0
[is_child] => 0
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-04 10:47:54
[updated_on] => 2015-09-05 22:48:01
)
[1] => stdClass Object
(
[category_id] => 2
[category_slug] =>
[category_glyphicon] => dddd
[category_name] => work
[is_parent] => 0
[is_child] => 0
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-04 11:41:18
[updated_on] => 2015-09-04 11:11:18
)
[2] => stdClass Object
(
[category_id] => 3
[category_slug] =>
[category_glyphicon] => mmm
[category_name] => enjoy
[is_parent] => 0
[is_child] => 0
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-04 11:41:52
[updated_on] => 2015-09-04 11:12:51
)
[3] => stdClass Object
(
[category_id] => 4
[category_slug] =>
[category_glyphicon] => mmm
[category_name] => for sale
[is_parent] => 1
[is_child] => 0
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-04 11:42:59
[updated_on] => 2015-09-04 11:12:59
)
[4] => stdClass Object
(
[category_id] => 5
[category_slug] =>
[category_glyphicon] => ccccc
[category_name] => for rent
[is_parent] => 1
[is_child] => 0
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-05 12:13:48
[updated_on] => 2015-09-04 11:43:48
)
[5] => stdClass Object
(
[category_id] => 6
[category_slug] =>
[category_glyphicon] => sss
[category_name] => villas
[is_parent] => 4
[is_child] => 1
[is_sub_child] => 0
[rf_flag] => 0
[status] => 1
[category_description] =>
[created_on] => 2015-09-05 12:14:57
[updated_on] => 2015-09-04 11:44:57
)
)