I have a sidebar with categories. as you can see here: http://kees.een-site-bouwen.nl/
The id of the category in within the url. with an uri segment(3) When you click on one of the categories for example webdesign. some factories are shown. these factories have a join with the categories. so when the category id = 11, the factories with category id=11 are shown.
but now i want to show how much factories are in that category. the output will show up between the
()
here: http://kees.een-site-bouwen.nl/
So my actual question is: how do i count_all_results() so it only shows me the factories who are located in the category?
What i've tried.
<?php
if (isset($results) && is_array($results)) {
foreach ($results as $key => $row) {
$id = $row->idcategorieen;
$segment3 = $this->uri->segment(3);
if ($id == $segment3) {
echo '<h2>Categorie:', ' ' , $row->Categorie;
echo '<h2>';
echo br(1);
echo '<p class="field">';
echo '<h3><label class="field">Aantal:</label></h3>', $this->db->count_all_results('bedrijven');
echo '</p>';
echo br(1);
break;
}
}
}
?>
<br />
<h4>Bedrijven</h4>
<hr>
<br />
<?php foreach($results as $item):?>
<p>Bedrijfsnaam: <a href="<?php echo base_url()?>home/showindividueel/<?php echo $item->idbedrijven?>">
<?= $item->Bedrijfsnaam ?></a><br /></p>
</tr>
<?php endforeach;?>
this shows me all of the factories in my database. but i only need the ones in the specific category.
Sidebar code:
echo '<ul>';
if(isset($cat) && is_array($cat)){
foreach($links as $k => $value)
{
echo '<li>';
echo '<br>';
echo '<a href="'.base_url().'home/categorie/'.$value->idcategorieen.' ">' .$value->Categorie. '</a>';
echo nbs(1);
echo '(';
echo ')';
echo '</li>';
}
}
echo '<ul>';
Thanks.