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: Dadal Yozshukasa
Country: Netherlands
Language: English (Spanish)
Genre: Sex
Published (Last): 24 September 2006
Pages: 368
PDF File Size: 5.76 Mb
ePub File Size: 4.32 Mb
ISBN: 943-4-59885-612-1
Downloads: 43044
Price: Free* [*Free Regsitration Required]
Uploader: Malabei

A view is simply codeignitee web page, or a page fragment, like a header, footer, sidebar, etc. In fact, views can flexibly be embedded within other views within other views, etc.

Creating a QuickStart Blog with CodeIgniter – Wrox

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 you 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.


Cdeating URL was similar to this:. If more than one 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.

Creating a QuickStart Blog with CodeIgniter

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 loading 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:.


Template Parser Class — CodeIgniter documentation

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. You can pass multi dimensional arrays, which creatiny 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 crdating 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 can be useful if you want to process eith 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. 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: