score:0

I manage to do it by doing something like this in my controller, I know it's not beautiful but it is fine for now

public function dashboard_project()
{   
    $thn = $this->input->post('tahun');
    $id = md5($this->session->userdata('id'));
    $data['rows'] = $this->pengguna_m->getPengguna($id)->row();

    $data['januari'] = $this->dashboard_m->get_kategori_totals('01',$thn)->num_rows();
    $data['februari'] = $this->dashboard_m->get_kategori_totals('02',$thn)->num_rows();
    $data['maret'] = $this->dashboard_m->get_kategori_totals('03',$thn)->num_rows();
    $data['april'] = $this->dashboard_m->get_kategori_totals('04',$thn)->num_rows();
    $data['mei'] = $this->dashboard_m->get_kategori_totals('05',$thn)->num_rows();
    $data['juni'] = $this->dashboard_m->get_kategori_totals('06',$thn)->num_rows();
    $data['juli'] = $this->dashboard_m->get_kategori_totals('07',$thn)->num_rows();
    $data['agustus'] = $this->dashboard_m->get_kategori_totals('08',$thn)->num_rows();
    $data['september'] = $this->dashboard_m->get_kategori_totals('09',$thn)->num_rows();
    $data['november'] = $this->dashboard_m->get_kategori_totals('10',$thn)->num_rows();
    $data['oktober'] = $this->dashboard_m->get_kategori_totals('11',$thn)->num_rows();
    $data['desember'] = $this->dashboard_m->get_kategori_totals('12',$thn)->num_rows();

    $data['title']= 'Aplikasi Saranabudi';
    $data['aktif']  = 'Jumlah Kategori Project';
    $data['judul_hal']= 'Dashboard Kategori Project';

    $this->load->view('layout/header',$data);
    $this->load->view('layout/sidebar',$data);
    $this->load->view('dashboard/pelanggan/home');
    $this->load->view('layout/footer');
}

score:0

Here's my simple syntax to count per month within a year

public function get_monthly_totals($theYear = ''){
    $select = "
        SELECT 
          COUNT(*) AS start_count,
          MONTH(start_date) as month
        FROM
           project
        WHERE 
           YEAR(start_date)='$theYear'
        GROUP BY
           MONTH(start_date)
    ";
    return $this->db->query($select);
}

Related Query

More Query from same tag