How to modify CodeIgniter calendar to handle multiple events per day?

后端 未结 1 930
再見小時候
再見小時候 2021-01-16 22:54

I am creating a calendar without jquery calendar plugin. I could retrieve the data which is in the database to the calendar. But when there are multiple data per day only on

相关标签:
1条回答
  • 2021-01-16 23:25

    If you want to show all four boxes for the dates which has data, try to change the get_calendar_data() foreach as below,

    $content = "";
    $lastDay = -1;
    $index = 0;
    foreach ($query->result() as $row) {
    
            if($lastDay != intval(substr($row->date_cal, 8, 2))){       
                if($index > 0 ){
                   if($content != ''){
                       $cal_data[$lastDay] = $content;
                       $content = '';
                   }
                }
                $index = 0;               
            }
    
    
            if ($row->title == 'GK' && $row->type == 'AM') {
                $content .= '<div class="gk_am">' . $row->title . ' ' . $row->type . '</div>';
            } else if ($row->title == 'GK' && $row->type == 'PM') {
                $content .= '<div class="gk_pm">' . $row->title . ' ' . $row->type . '</div>';
            }else if ($row->title == 'RP' && $row->type == 'AM') {
                $content .= '<div class="rp_am">' . $row->title . ' ' . $row->type . '</div>';                
            } else if ($row->title == 'RP' && $row->type == 'PM') {
                $content .= '<div class="rp_pm">' . $row->title . ' ' . $row->type . '</div>';                
            }
    
            $lastDay = intval(substr($row->date_cal, 8, 2));
            $index++;     
    
        }
    
        if($lastDay != -1 && $content != ''){
            $cal_data[$lastDay] = $content;
        }
    

    Let me know whether it works now or not.

    0 讨论(0)
提交回复
热议问题