CodeIgniter: Preparing Database

CodeIgniter Step By Step Tutorial: After set database configuration,we will learn about showing data from database in CodeIgniter. But, before that, we prepare a database for practice. This post create a database named “ci” and a table named “books”. We use phpMyAdmin for easy.
1. Open your phpmyadmin.
2. Enter database name “ci” in create new database field.
3. Click Create button. Your database will be created.
create database
Database create successfullycreate database successfully

4. Create new table by entering name of new table at create new table field.
5. Enter number of fields.
6. Click Go button.
codeigniter - table creating use phpmyadmin
7. Enter name of field, type, and length
enter field name
8. Choose auto increment and check primary key for primary key field. and Click Save button.
set pripary key and click save
Table create successfully
table create successfully
9. Now, we insert data. Click Insert tab.
click insert tab
10. Enter data.
11. Click Go for saving.
insert dummy data

So the table is created.
The table full script is

CREATE TABLE IF NOT EXISTS `books` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `isbn` varchar(256) NOT NULL,
  `title` varchar(256) NOT NULL,
  `description` varchar(256) NOT NULL,
  `author_name` varchar(256) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

Insert this dummy data

INSERT INTO `books` (`id`, `isbn`, `title`, `description`, `author_name`) VALUES
(1, '1847192971', 'Building Powerful and Robust Websites with Drupal 6', 'Drupal Books', 'David Mercer'),
(2, '1847192564', 'Object-Oriented Programming With PHP5', 'Php 5 books', 'Hasin Hayder');

 

the coder

Got something to say? Go for it!

*

 
More in beginners (4 of 10 articles)