select('categories', [ 'catid', 'catname' ]); foreach ($cats as $cat) { $itemcount = $database->count('items', ['catid' => $cat['catid']]); ?>