Create a simple blog using CodeIgniter 2 – Part 2

CodeIgniter Logo

In this CodeIgniter tutorial, I’m going to show you how to create a blog post with comment function with CodeIgniter 2. You can download the code or just preview the final product first. In this version of code, I’ve created a simple template for our blog.

You can preview the part 1 of this tutorial at Create a simple blog using CodeIgniter 2 – Part 1.

1. Create a table for comment

CREATE TABLE IF NOT EXISTS `comment` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`entry_id` int(11) NOT NULL,
`comment_name` varchar(255) NOT NULL,
`comment_email` varchar(255) NOT NULL,
`comment_body` text NOT NULL,
`comment_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`comment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Continue reading “Create a simple blog using CodeIgniter 2 – Part 2”

Create a simple blog using CodeIgniter 2 – Part 1

CodeIgniter Logo

This entry will demonstrate to you on how to code a simple blog by using CodeIgniter 2. You may use whatever web server environment that you prefer such as Xampp, Lamp, Wamp, or Mamp. In this tutorial, I would like to use Wamp.

At the end of the tutorial, you should have a simple blog system with comment function. To download the complete source code, scroll down to the end of this tutorial. You also may want to view the final product first.

1. Setup a database

In the database named as blog, we will create a table, table ENTRY. The ENTRY table has columns such as entry_id, entry_name, entry_body, and entry_date (This is just a sample). The code is as below:

CREATE TABLE IF NOT EXISTS `entry` (
`entry_id` int(11) NOT NULL AUTO_INCREMENT,
`entry_name` varchar(255) NOT NULL,
`entry_body` text NOT NULL,
`entry_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`entry_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Continue reading “Create a simple blog using CodeIgniter 2 – Part 1”