[eluser]herbageonion[/eluser]
Hi,
I'm trying to get a calendar working for a full year and then highlight the days that have entries in the database.
The problem is, the days keep overlapping into subsequent months. My code is below. Anyone have any suggestions?
Cheers,
- E
Code:
$cal_data = array();
for ( $i=1; $i<13; $i++ )
{
$like_date = ($i < 10) ? $seg_3.'-0'.$i : $seg_3 .'-'. $i;
// Query DB
$query = $this->db->query("SELECT * FROM `tbl_courses` WHERE FromDate LIKE '%$like_date%'");
foreach ($query->result() as $row)
{
$cal_day = mdate_to_human($row->FromDate, 'd');
$year = mdate_to_human($row->FromDate, 'Y');
$month = mdate_to_human($row->FromDate, 'm');
$day = mdate_to_human($row->FromDate, 'd');
$cal_data[$cal_day]= $this->config->item('site_url') .'coursedesc/index/'. $year .'/'. $month .'/'. $day.'/';
}
$data['calendar'][$i] = $this->calendar->generate($seg_3, $i, $cal_data);
}