I have a Table ANKETADATA in my database which containts a column PROVO. I want to have output like this:
povremeno : 15. (The number show how many times found this row in column PRVO)
nikad : 40.
MODEL:
$anketadb = $this->load->database('anketa',TRUE);
$anketadb->select('prvo');
$anketadb->from('anketadata');
$anketadb->group_by('prvo');
$result = $anketadb->get();
$result = $result->result_array();
$count = array('povremeno' => 0, 'nikad' => 0, 'svakibroj' => 0, 'prodajemkupujem' => 0);
foreach($result as $row){
switch($row){
case 'povremeno' : $count['povremeno']++; break;
case 'nikad' : $count['nikad']++; break;
case 'svakibroj' : $count['svakibroj']++; break;
case 'prodajemkupujem' : $count['prodajemkupujem']++; break;
}
}
return $count;
CONTROLLER:
$this->load->model('anketerezultati_model');
$data['count'] = $this->anketerezultati_model->prvo();
$this->load->view('ankete/rezultatiankete', $data);
VIEW:
echo "povremeno".$count['povremeno'];
echo "nikad".$count['nikad'];
The result is 0 for both. I cannot find the mistake.