How to count the date to make a list of events?
I'm using Codeigniter V2.1.3 and I have a calendar template that have a
scheduling stuff and I want to count the events in a particular date. Here
is my database:
----Table: schedule -----
id | materialID | borrowerID | date_reserve |
------------------------------------------------
1 | 7 | 7 | 2013-08-16 |
2 | 10 | 10 | 2013-08-16 |
1 | 12 | 13 | 2013-08-18 |
What I want is in my calendar template the total event for the
date=2013-08-16 will be 2 events. Here is my code which is not working coz
it keeps on sending me only 1 event maybe you could figure out where is my
mistake in here:
$query =
$this->db->select('*')->from('schedule')->like('date_reserve',
"$year-$month")->get();
$cal_data = array();
foreach ($query->result() as $row) {
$index = ltrim(substr($row->date_reserve,8,2), '0');
$cal_data[$index] = count($row->borrowerID). 'event(s)';
}
return $cal_data;
Any help?
No comments:
Post a Comment