 <p>I fixed my problem using a new function in my controller.</p> <p>My controller:</p> <pre><code>$data['counts'] = $this-&gt;bedrijven_model-&gt;bedrijf_categorie(); </code></pre> <p>My model:</p> <pre><code>function bedrijf_categorie() { $sql = " SELECT count(b.idbedrijven) as ItemCount, c.Categorie as Categorie FROM `bedrijven` b INNER JOIN `bedrijfcategorieen` bc ON bc.idbedrijven = b.idbedrijven INNER JOIN `categorieen` c ON c.idcategorieen = bc.idcategorieen GROUP BY c.idcategorieen "; $query = $this-&gt;db-&gt;query($sql); return $query-&gt;result_array(); } </code></pre> <p>my views:</p> <pre><code> &lt;?php echo '&lt;ul&gt;'; foreach($counts as $count){ echo '&lt;li&gt;'; echo '&lt;a href="'.base_url().'home/categorieen/'.$count['Categorie'].' "&gt;' .$count['Categorie']. '&lt;/a&gt;'; echo nbs(1); echo '('; echo $count['ItemCount']; echo ')'; echo '&lt;/li&gt;'; } echo '&lt;/ul&gt;'; ?&gt; </code></pre> <p>Anyway. thanks people who helped.</p>