在计算结果时是否有可能获取数组 我正在尝试创建一个考勤人数。礼物,缺席,总数。每个会议的会议。身份证和学生证
这是我的数据库
SCHED_ID |STUDENT_ID |DATE | A_STAT
1234567 |2014-000003 |08/01/14 |Absent
123456 |2014-000003 |08/04/2014 |Present
1234567 |2014-000003 |08/10/2014 |Present
123456 |2014-000003 |08/10/2014 |Present
输出应该是这样的
主题总数|现在的天数|缺席的天数 dasdasdasd 3 2 1 testing123 3 2 1 ASDASD 1 0 1
但它总是像这样
主题总数|现在的天数|缺席的天数
dasdasdasd 3 1 1
testing123 3 1 1
ASDASD 3 1 1
$ query = $ this-> db-> query(“SELECT * FROM(tbl_schedule c,tbl_subject d,tbl_attendance e)其中e.SCHED_ID = c.SCHED_ID AND d.SUBJECT_CODE = c.SUBJECT_CODE AND(e .STUDENT_ID ='$ si')GROUP BY e.SCHED_ID“) - > result_array();
$ query1 = $ this-> db-> query(“SELECT * FROM(tbl_schedule c,tbl_subject d,tbl_attendance e),其中e.SCHED_ID = c.SCHED_ID AND d.SUBJECT_CODE = c.SUBJECT_CODE和e。 A_STAT ='现在'AND(e.STUDENT_ID ='$ si')GROUP BY e.SCHED_ID和e.A_STAT“) - > num_rows();
$ query2 = $ this-> db-> query(“SELECT * FROM(tbl_schedule c,tbl_subject d,tbl_attendance e)其中e.SCHED_ID = c.SCHED_ID AND d.SUBJECT_CODE = c.SUBJECT_CODE AND e。 A_STAT ='缺席'AND(e.STUDENT_ID ='$ si')GROUP BY e.SCHED_ID和e.A_STAT“) - > num_rows();
$ query3 = $ this-> db-> query(“SELECT * FROM(tbl_schedule c,tbl_subject d,tbl_attendance e)其中e.SCHED_ID = c.SCHED_ID AND d.SUBJECT_CODE = c.SUBJECT_CODE AND(e .STUDENT_ID ='$ si')GROUP BY e.SCHED_ID“) - > num_rows();
for($i=0;$i<sizeof($query);$i++){
$data[$i][0]=$query1; // present
$data[$i][1]=$query2; //absent
$data[$i][2]=$query3; //total
$data[$i][3]=$query[$i]['SUBJECT _DESC']; // subj
}
return $data;