แผนภูมิสูง :: Codeigniter

    <?php
for ($i= 1; $i <= 12; $i++) {
    if ( $i <= 9)  { 
    $month = '0' . $i;
    } else {
    $month = $i; 
    }
   $date = date("d");
    $year = date("Y");
    //$month = date('Y-m-d', strtotime(date('Y').'-'.$i.'-'.date('d')));
    $month = date('Y-m-d', strtotime($date."-" . $i ."-". $year));  
    $where = array('created_time >=' => $month . " 00:00:00", 'created_time <=' => $month . " 23:59:59");
    $i_result[$month] = count($this->db->where($where)->get('tbl_opportunities')->result());

}    var_dump( $i_result); 
   ?>

ฉันกำลังพยายามสร้างแผนภูมิสรุปรายเดือน มันให้ผลลัพธ์ที่ถูกต้องสำหรับสถิติของวันนี้ แต่ในวันถัดไปสถิติจะรีเฟรชและให้สถิติใหม่ แต่อยากได้ผลรวมสะสมของเดือนนั้นๆ (พื้นฐานรายเดือน) มีข้อเสนอแนะอะไรบ้าง?..

อ้างอิงถึงรูปภาพ - เพียงแถบสีน้ำเงิน:

ป้อนคำอธิบายรูปภาพที่นี่


person Adam Harris bin Suppuramany    schedule 29.11.2016    source แหล่งที่มา
comment
คำถามของคุณไม่ชัดเจนนัก แต่เป็นเพียงคำใบ้ ให้ทำอะไรสักอย่างเกี่ยวกับคำถามของคุณ หากคุณต้องการผลลัพธ์สะสมรวมในหนึ่งเดือน ให้ใช้ SUM   -  person Ronald    schedule 29.11.2016
comment
เรียนคุณโรนัลด์ ตัวอย่างใด ๆ ฉันจะใช้ SUM ได้อย่างไร ไม่เป็นไร   -  person Adam Harris bin Suppuramany    schedule 29.11.2016


คำตอบ (1)


จัดการแก้ไขปัญหา...Tq

โดยแทนที่บรรทัดนี้

$where = array('created_time >=' => $month . " 00:00:00", 'created_time ‹=' => $month . " 23:59:59");

to

$where = array('created_time >=' => $year . "-" . '0' . $i . '-' . '01', 'created_time ‹=' => $year . "-" . '0 ' . $i . '-' . '31');

person Adam Harris bin Suppuramany    schedule 29.11.2016