CodeIgniter from Scratch: The Calendar Library
videos

CodeIgniter from Scratch: The Calendar Library

This entry is part 10 of 17 in the CodeIgniter From Scratch Session
« PreviousNext »

In this tenth episode of the CodeIgniter From Scratch screencast series, we will be exploring the Calendar library. We are also going to utilize the database class and jQuery AJAX. I will show you how to build a simple and CSS-styled calendar page, which will have the ability to store and display content for each day.

Final Example

Catch Up

Day 10: The Calendar Library

Other Viewing Options

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Shareed2k

    how to make a few events in a same day ?

  • http://twitter.com/matteopolati Matteo Polati

    Very very useful, but I found a problem with days of months from one to nine. In this tutorial you don’t show what appens if i insert a data for example the second or the third day of month. Simply don’t work (for me).

    This because mysql return first days leading by zero (01,02,03 etc..) but calendar class accepts only one digit indexes (1,2,3,4…).

    I solved it by adding a little ‘filter’ for days leading by zero :

    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 $row) {
    $index = ltrim(substr($row->date,8,2), '0'); // this is the magic !!
    $cal_data[$index] = $row->data;
    }
    return $cal_data;
    }

    I hope can save headache for someone..
    Bye.

    • http://www.facebook.com/mspamrita Amrita Poddar

      Though I was able to find the problem, I was wondering how to solve it. And this indeed worked like a magic!
      Thanks a lot :)

  • SteveB_LA

    Matteo – Thank you. That worked.

  • http://www.facebook.com/israel.parraconejero Israel Parra Conejero

    Bravo sir, great and easy!

  • http://www.facebook.com/Sagar.S.Shinde Sagar Subhash Shinde

    I want to know the software similar to yours but can be used on windows. any suggestions plz.

  • sanjaya

    Undefined property: stdClass::$data

    why this error?