php - Codeigniter highcharttable统计一个月有多少数据

标签 php mysql codeigniter charts highcharts

我有这个 project 表,你可以在下面看到,从下表我想制作一个图表,其中包含那个月有多少 project

id | project_name | start_date |
1  | proj1        | 2017-09-01 | 
2  | proj2        | 2017-09-01 |
3  | proj3        | 2017-09-01 |
4  | proj4        | 2017-08-01 | 
5  | proj5        | 2017-08-01 |

到目前为止我所做的是制作一个模型,然后我很困惑接下来应该做什么,因为我创建的模型不是动态的,它只读取某个月份,在这种情况下是 month=09

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

enter image description here

我想制作一个像上面那样的图表,我使用的插件是 highcharttable,它将 html 表格数据转换成图表,我是如何制作这样的图表的,我是如何制作一个月的即使其中没​​有数据也存在,以及如何将数据连接到正确的月份?

最佳答案

我设法通过在我的 Controller 中做这样的事情来做到这一点,我知道它不漂亮但现在没问题

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');
}

关于php - Codeigniter highcharttable统计一个月有多少数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46880522/

相关文章:

javascript - 我不明白为什么我的 ajax 没有将数据发送到我的 php 文件

PHP 不小心创建了无限循环?

mysql - 如何在ORDER BY中使用CASE函数?

php - 如何在 Laravel 5.1 中编写原始查询?

php - 如何知道表中的任何行是否满足条件

mysql - CodeIgniter 从两个以上的表中获取记录

php - Codeigniter如何在php codeigniter中从数据库检索base_url

php - 无法读取来自 RabbitMQ 的所有消息

php - 是否有一种标准的方法来处理与 PHP 中的条件分开的设计 (CSS)?

Mysql Order By 包含数字和字母的字符串