to give you a quick start ill explain how to create your first codeigniter project. To input data into the database you need to create a form where you can input the information to be stored. This means you’ll be needing a form with two fields, . Quick Start: Usage Examples · Database Configuration · Connecting to a Database · Running Queries · Generating Query Results · Query Helper Functions.

Author: Tojinn Zolojin
Country: Tunisia
Language: English (Spanish)
Genre: Relationship
Published (Last): 27 May 2010
Pages: 129
PDF File Size: 15.79 Mb
ePub File Size: 9.80 Mb
ISBN: 643-7-20450-637-8
Downloads: 27566
Price: Free* [*Free Regsitration Required]
Uploader: Yozshuzahn

A view is simply a web page, or a page fragment, like a header, footer, sidebar, etc.

CodeIgniter User Guide — CodeIgniter documentation

In fact, views can flexibly be quickstaft within other views within other views, etc. Views are never called directly, they must be loaded by a controller. Remember that in an MVC framework, the Controller acts as the traffic cop, so it is responsible for fetching a particular view. If codfigniter have not read the Controllers page you should do so before continuing. Now, open the controller file you made earlier called Blog. If you visit your site using the URL you did earlier you should see your new view.


The URL was similar to this:.

If more than crewting call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view.

That might look something like this:. Your view files can also be stored within sub-directories if you prefer that type of organization. When doing so you will need to include the directory name quickstary the view. Data is passed from the controller to the view by way of an array or an object in the second parameter of the view loading method.

Here is an example using an array:. Now open your view file and change the text to variables that correspond to the array keys in your data:. The data array you pass to your view files is not limited to simple variables.

Create news items — CodeIgniter documentation

You can pass multi dimensional arrays, which can be looped to generate multiple rows. For example, if you pull data from your database it will typically be in the form of a multi-dimensional array.


If you are not familiar with it you can read about it here. There is a third optional parameter lets you change the behavior of the method so that it returns data as a string rather than sending it to your browser.

This qiickstart be useful if you want to process the data in some way.

If you set the parameter to TRUE boolean it will return data. The default behavior is false, which sends it to your browser.

Creating a QuickStart Blog with CodeIgniter

Remember to assign it to a variable if you want the data returned:. That might look something like this: Here is an example using an array: Note If you use an object, the class variables will be turned into array elements.

Add this to your controller: Remember to assign it to a variable if you want the data returned: