<div class="input-group-btn"> <button onclick="myAlert()" class="btn btn-default"><i class="fa fa-search"></i></button> </div> </div> </div> </div> <!-- /.box-header --> <div class="box-body table-responsive"> <table class="table table-hover"> <tr> <th>Name</th> <th>Sub Categories</th> <th>Action</th> </tr> <?php $parentList = $parentController->getAll(); if ($parentList) { foreach ($parentList as $parent) { ?> <tr> <td><?php echo $parent->getCategory(); ?> </td> <td><?php if ($cc = $categoryController->getByParent($parent->getId())) { echo count($cc); } else { echo "0"; } ?>