Welcome Guest, Not a member yet? Register   Sign In
Calendar Problems, Days Overlapping
#1

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

[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.
#3

[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.




Theme © iAndrew 2016 - Forum software by © MyBB