Building a CodeIgniter Calendar helper with database results

CodeIgniter comes with a really useful calendar helper that allows you to display months in a grid. It is possible to develop functionality to pull events from a database (such as a table that stores diary appointments) and indicate to the user if there is an appointment on a given day.

Getting ready

As we're storing appointments in a database, we'll need a database table. Copy the following code into your database:

CREATE TABLE `appointments` ( `app_id` int(11) NOT NULL AUTO_INCREMENT, `app_date` varchar(11) NOT NULL, `app_url` varchar(255) NOT NULL, `app_name` varchar(255) NOT NULL, PRIMARY KEY (`app_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; INSERT INTO `appointments` ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.