如何将数据库中的数据放入多个日历中

时间:2019-04-08 01:33:41

标签: javascript php jquery ajax codeigniter

我是使用Codeigniter制作事件日历的新手。您是否知道如何将某些数据放入在数据库中检索的日历单元中。你能给我一个主意吗?或者如果可能的话。请帮助我。

这是我获取3个月日历的代码。

*控制器*

public function displayindex($year = null, $month = null){

        $this->load->model('CalendarModel');
        $this->CalendarModel->generate($year, $month);

        $month2_year = date("Y",strtotime("-1 month"));
        $month2_month = date("m",strtotime("-1 month"));
        $month3_year = date("Y",strtotime("+1 month"));
        $month3_month = date("m",strtotime("+1 month"));
        $cal_data['month1'] = $this->calendar->generate();
        $cal_data['month2'] = $this->calendar->generate($month2_year, $month2_month);
        $cal_data['month3'] = $this->calendar->generate($month3_year, $month3_month);
        $this->load->view('calendar_users', $cal_data);
    } 

*型号*

function generate ($year, $month){

        $this->conf = array(
            'start_day' => 'sunday'
         );

        $this->conf['template'] = '

                    {table_open}<table border="0" cellpadding="0" cellspacing="0" class="calendar">{/table_open}

                    {heading_row_start}<tr>{/heading_row_start}

                    {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
                    {heading_title_cell}<th colspan="{colspan}"  class="monthname">{heading}</th>{/heading_title_cell}
                    {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

                    {heading_row_end}</tr>{/heading_row_end}

                    {week_row_start}<tr class="weekday">{/week_row_start}
                    {week_day_cell}<td>{week_day}</td>{/week_day_cell}
                    {week_row_end}</tr>{/week_row_end}

                    {cal_row_start}<tr class="days">{/cal_row_start}
                    {cal_cell_start}<td>{/cal_cell_start}
                    {cal_cell_start_today}<td>{/cal_cell_start_today}
                    {cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}

                    {cal_cell_content}<div class="day_num">{day}</div><div>{content}</div>{/cal_cell_content}
                    {cal_cell_content_today}<div class="day_num highlight">{day}</div><div>{content}</div>{/cal_cell_content_today}

                    {cal_cell_no_content}<div class="day_num">{day}</div>{/cal_cell_no_content}
                    {cal_cell_no_content_today}<div class="day_num highlight">{day}</div>{/cal_cell_no_content_today}

                    {cal_cell_blank}&nbsp;{/cal_cell_blank}

                    {cal_cell_other}{day}{/cal_cel_other}

                    {cal_cell_end}</td>{/cal_cell_end}
                    {cal_cell_end_today}</td>{/cal_cell_end_today}
                    {cal_cell_end_other}</td>{/cal_cell_end_other}
                    {cal_row_end}</tr>{/cal_row_end}

                    {table_close}</table>{/table_close}


        ';

        $this->load->library('calendar', $this->conf);
        $caldata = array (
            15 => 'yes',
            17 => 'no'
        );
        // $cal_data = $this->get_calendar_data($year, $month);    
        return $this->calendar->generate($year, $month, $caldata);      
    }

*视图*

<div class="row">
  <div class="column" name="">
  <?php echo $month2; ?>
  </div>
  <div class="column">
  <?php echo $month1; ?>
  </div>
  <div class="column">
    <?php echo $month3; ?>
  </div>

0 个答案:

没有答案