I am facing problem in getting more than 1 result on event calendar.
I have more than 1 exam on same day ..which i need to display.. but whats going is that, it is showing only the 1 result of same day..
my query is fetching all exams of same day but not displaying it on calendar.
My Code:
<?php
class Mycal_model extends CI_Model {
var $conf;
function Mycal_model(){
//parent::CI_Model();
$this->conf = array(
'start_day' => 'monday',
'show_next_prev' =>true,
'next_prev_url' => base_url().'mycal/display',
'day_type' =>'short');
$this->conf['template'] = '
{table_open}<table border="1" cellpadding="0" cellspacing="0" class="calendar">{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><span class="caret left"></span></a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}"><span class="caret right"></span></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<th style="color: black;font-size:20px;">{week_day}</th>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr class="days">{/cal_row_start}
{cal_cell_start}<td class="day">{/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 class="content"><p><a href="#"><span>{content}</span></a></p></div>
{/cal_cell_content}
{cal_cell_content_today}
<div class="day_num">{day}</div>
<div class="content">{content}</div>
{/cal_cell_content_today}
{cal_cell_no_content_today}
<div class="day_num highlights">{day}</div>
{/cal_cell_no_content_today}
{cal_cell_no_content_today}
<div class="highlights">{day}</div>
{/cal_cell_no_content_today}
{cal_cell_blank} {/cal_cell_blank}
{cal_cell_other}{day}{/cal_cell_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}
';
}
function get_calendar_data($year, $month){
$query = $this->db->select('ee_exam_date,ee_sname')->from('vm_entrance_exams')->like('ee_exam_date',"$year-$month",'after')->get();
$cal_data = array();
foreach($query->result() as $row){
$cal_data[substr($row->ee_exam_date,8,2)] = substr($row->ee_sname,0,50);
}
return $cal_data;
}
function add_calendar_data($ee_exam_date, $ee_sname){
if($this->db->select('ee_exam_date')->from('vm_entrance_exams')
->where('ee_exam_date',$ee_exam_date)->count_all_results()){
$this->db->where('ee_exam_date',$ee_exam_date)
->update('vm_entrance_exams',array(
'ee_exam_date' => $ee_exam_date,
'ee_sname' => $ee_sname
));
}
else{
$this->db->insert('vm_entrance_exams',array(
'ee_exam_date' => $ee_exam_date,
'ee_sname' => $ee_sname
));
}
}
function generate ($year,$month){
$this->load->library('calendar',$this->conf);
$cal_data = $this->get_calendar_data($year, $month);
return $this->calendar->generate($year,$month,$cal_data);
}
}
My result:
stdClass Object ( [ee_exam_date] => 2017-12-21 [ee_sname] => DNB CET SS ) stdClass Object ( [ee_exam_date] => 2017-12-03 [ee_sname] => IIFT ) stdClass Object ( [ee_exam_date] => 2017-12-17 [ee_sname] => SNAP ) stdClass Object ( [ee_exam_date] => 2017-12-21 [ee_sname] => IBSAT ) stdClass Object ( [ee_exam_date] => 2017-12-21 [ee_sname] => FMGE ) stdClass Object ( [ee_exam_date] => 2017-12-10 [ee_sname] => Maha TAIT ) stdClass Object ( [ee_exam_date] => 2017-12-10 [ee_sname] => C-CAT ) stdClass Object ( [ee_exam_date] => 2017-12-17 [ee_sname] => CPT EXAMINATION )