# Categories and Sub Categories

**URL:** <https://forum.kirupa.com/t/categories-and-sub-categories/238872>\
**Category:** programming\
**Created:** [September 16, 2007, 4:38pm UTC](https://forum.kirupa.com/t/categories-and-sub-categories/238872 "2007-09-16T16:38:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamerp](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dreamerp](https://forum.kirupa.com/u/dreamerp)\
**Post date:** [September 16, 2007, 4:38pm UTC](https://forum.kirupa.com/t/categories-and-sub-categories/238872/1 "2007-09-16T16:38:32Z")

</div>

Hello,

I am working on a catalog that would consist of top level categories and sub categories underneath that. What can I use in PHP that will loop the sub categories so I can have unlimited categories under unlimited categories… lol. For example, I could have Top Level \>\>\> Sub 1 \>\>\> Sub 2 Under Sub 1 \>\>\> Sub 3 Under Sub 2

I was thinking I could use some like

```php
 for ($i = 0; $i < 3; $i++)

```

but I couldn’t get anything of that sort to work, I tried variations and also put in a variable for the 3 that would equal mysql\_num\_rows of the database, I am just confused!!

Please help, thanks!
