Welcome Guest, Not a member yet? Register   Sign In
problem loading data in Calendar...
#1

[eluser]Unknown[/eluser]
Hi everyone,
I am trying to load some data from the Database into the calendar library.

Problem:
The data is not getting loaded even though the calendar is display properly.
Just the data is not getting loaded.


Address Bar : http://localhost/ci/index.php/mycal/display/2012/01

I have attached a pic of what my page looks like...

There should have been some content 5th Jan 2012 calendar ...

The Code:

Controller:::

Code:
<?php

class Mycal extends CI_Controller{
function __construct(){
  parent::__construct();
}

function index(){
  //$data['main_content'] = 'cal_view';
  //$this -> load -> view('include/template', $data);
}

function display($year = null, $month = null){
  $this -> load -> model('Mycal_model');
  $data = array(
   'calendar' => $this -> Mycal_model -> generate($year, $month),
   'main_content' => 'mycal'
  );
  
  $this -> load -> view('include/template', $data);
  
}
}


Model:::


Code:
<?php

class Mycal_model extends CI_Model{
var $conf;

function __construct(){
  parent::__construct();

  $this -> config = array(
   'start_day' => 'sunday',
   'show_next_prev' => true,
   'next_prev_url' => base_url().'index.php/mycal/display'
  );

function get_calendar_data($year, $month){
  $query = $this -> db -> select('date, data') -> from('calendar') -> like('date', "$year-$month", 'after') -> get();
  
  $cal_data = array();
  
  foreach( $query -> result() as $cal_row ){
   $cal_data[substr($cal_row -> date, 8, 2)] = $cal_row -> data;
  }
  
  return $cal_data;
}

function generate($year, $month){
  

  $this -> load -> library('calendar', $this -> config);
  
  $cal_data = $this -> get_calendar_data($year, $month);
  
  return $this -> calendar -> generate($year, $month, $cal_data);
}
}

View::

Code:
<?php echo $calendar; ?>


Any help will be appreciated Smile




Theme © iAndrew 2016 - Forum software by © MyBB