CodeIgniter Forums
Calendar Problems, Days Overlapping - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Calendar Problems, Days Overlapping (/showthread.php?tid=2009)



Calendar Problems, Days Overlapping - El Forum - 07-11-2007

[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);
}



Calendar Problems, Days Overlapping - El Forum - 07-11-2007

[eluser]sophistry[/eluser]
how about clearing the variable $cal_day ?
Code:
$cal_day='';
// OR
unset($cal_day);

also, there is a lot of redundancy in this code... you need to take a closer look at it and trim out the fat.


Calendar Problems, Days Overlapping - El Forum - 07-12-2007

[eluser]herbageonion[/eluser]
Hey, ya setting the $cal_data to an empty array did the job.

Quote:there is a lot of redundancy in this codeā€¦ you need to take a closer look at it and trim out the fat.

I know, its just a rough version to get everything working. I'll get all the crap out there soon enough.

Thanks for your help.