title: Passing Data From Database into CodeIgniter Calendar Library
body: <p>Disclaimer: I'm new to Web Development</p>
  
  <p>So Far: I've been passing primary key data from a MySQL database table into the id="" field of the calendar class library list item that is displayed on the calendar when generated, and I've also been passing another value associated with the row of its respective primary key to the list item as well.</p>
  
  <p>Scenario: I'm needing to pass another value from the same respective row of the primary key into the class="" of the list item, and I've hit a wall. I may need to create a new function in my modal, or do something within the controller where said calendar is generated, or I may be totally overlooking something completely simple. Regardless, I could use some very appreciated help. Thank you so much!</p>
  
  <p>P.S. Please let me know if you need anymore information to help me out. Thanks again! You're all wonderful!</p>
  
  <p>Model:</p>
  
  <pre><code>class Events_model extends crud_model {
  
      public function __construct()
      {
          parent::__construct();
  
          $this-&gt;pk = 'id';
          $this-&gt;table_name = 'events';
      }
  
      public function get_events_for_calendar($user_id, $year = FALSE, $month = FALSE)
      {
  
          if ( ! $year )
          {
              $year = date("Y");
          }
  
          if ( ! $month )
          {
              $month = date("m");
          }
  
          $this-&gt;db-&gt;where("user_id", $user_id);
          $events = parent::get_all();
  
          $cal_events = array();
  
          foreach ($events as $e)
          {
              if ( date("Y", $e-&gt;date) == $year &amp;&amp; date("m", $e-&gt;date) == $month)
              {       
                  $day = intval( date("d", $e-&gt;date));
  
                  //Swap out to change between displaying type or title of events listed -lrussell810
  
                  //$cal_events[$day][$e-&gt;id] = $e-&gt;type;
                  $cal_events[$day][$e-&gt;id] = $e-&gt;title;
              }
          }
          return $cal_events;
      }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>$this-&gt;load-&gt;library('calendar', $config);
  
          $title['title'] = 'Planner';
  
          $data = $this-&gt;events-&gt;get_events_for_calendar($this-&gt;end_user-&gt;id, $this-&gt;uri-&gt;segment(4), $this-&gt;uri-&gt;segment(5));
  
          $calendar['calendar'] = $this-&gt;calendar-&gt;generate($this-&gt;uri-&gt;segment(4), $this-&gt;uri-&gt;segment(5), $data);
  
          $this-&gt;load-&gt;view('public/head_view', $title);
          $this-&gt;load-&gt;view('user/header_view');
          $this-&gt;load-&gt;view('user/planner_view', $calendar);
          $this-&gt;load-&gt;view('user/footer_view');
  </code></pre>
  
  <p>Calendar Library:</p>
  
  <pre><code>// If more than one event on the same day
                        if (is_array($data[$day]))
                        {
                          $several_events = '';
                          foreach ($data[$day] as $key =&gt; $value)
                          {
                            $several_events .= '&lt;li class="" id="'.$key.'"&gt;'.$value.'&lt;/li&gt;';
                          }
                          $out .= str_replace('{day}', $day, str_replace('{content}', $several_events, $temp));
                        }
  </code></pre>
  
  <p>Other Calendar Library Information:</p>
  
  <pre><code>// --------------------------------------------------------------------
  
      /**
       * Initialize the user preferences
       *
       * Accepts an associative array as input, containing display preferences
       *
       * @access  public
       * @param   array   config preferences
       * @return  void
       */
      function initialize($config = array())
      {
          foreach ($config as $key =&gt; $val)
          {
              if (isset($this-&gt;$key))
              {
                  $this-&gt;$key = $val;
              }
          }
      }
  </code></pre>