Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

[Solved] Count Users By Month

$
0
0
On database column date_reg looks like 2016-08-17

I would like to be able to count how many users have joined up in that month

I tried $string = explode('-', 'the_row_from_db'); but did not work.

Question how can I count up monthly users for each of the months. So if there were two dates like 2016-08-17 and 2016-08-10 would echo 2


PHP Code:
<?php

class Graph extends MX_Controller {

    public function 
index() {
        echo 
$this->getUserTotalByMonth('aug'); // month would be 08
        
return $this->load->view('template/dashboard/graph_view');
    }

    public function 
getUserTotalByMonth() {
        
$this->db->select('date_reg');
        
$this->db->from('user');
        
$query $this->db->get();

        if (
$query->num_rows() > 0) {
            return 
$query->num_rows();
        } else {
            return 
false;
        }
    }


Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>