CodeIgniter

CodeIgniter

 

How to Download:-

click on this link  http://codeigniter.com/download.php

 

How to Install:-

And you found the zip folder and Exctract the zip folder and copy in the  C:\xampp\htdocs\codeigniter

 

How to Setup With NetBeans:-

 

  • start netBeans
  • click file menu and new project
  • and choose the project and click next next…

 

 

 

How to Start:-

  • choose your project and right click and then click on run.

 

How to make a new page:-

 

How to make a new controller:-

  • click on this file application/controllers/welcome.php
  • And copy and make a new file as a ravindra.php
  • And  paste all data.
  • And change the class name.
  • And Make a function and call the view page.

class ravindra extends CI_Controller {

public function index()

{

$this->load->view(‘ravi’);

}

}

 

How to make a new view:-

  • click on this application/views/
  • And create a new php file name ravi.php
  • And write the php/html code. in this file

 

Ex.    <?php   echo “Hey “;  ?>

 

 

How to run a new page:-

 

  • Open a browser and paste thehttp://localhost/codeigniter/index.php/ravindra
  • In this Codeigniter is a Framework and index.php is starting page and ravindra is a controller and in this controller called a index method  Automatically.

 

 

How to create a more function in same controller:-

  • Open application/controllers/ravindra.php
  • And create the more functaions.

public function index()

{

$msg = “My Name is Ravi”;

$this->load->view(‘ravi’);

}

public function First()

{

$msg = “My Name is Ravi”;

echo $msg.”<br/>”;

// $this->load->view(‘ravi’);

}

public function sec()

{

$a = 5;

$b= 10;

$c=$a+$b;

echo “your sum is”.$c.”<br/>”;

// $this->load->view(‘ravi’);

}

 

 

How to run all controller one by one:-

  • http://localhost/codeigniter/index.php/ravindra/sec
  • http://localhost/codeigniter/index.php/ravindra/first

 

 

How to make the design in view:-

<html>

<head>

<title>Welcome User</title>

<link href=”http://localhost/CodeIgniter/data/css/user1.css” type=”text/css” rel=”stylesheet” />

</head>

<body>

<div id=”main”>

<div id=”first”><center><span style=”font-family:georgia;”>DEMO Manifest</span></center></div>

<div id=”menu”>

<div class=”menubar”><a href=”index.php”>Home</a></div>

<div class=”menubar”><a href=”#”>Aboutus</a></div>

<div class=”menubar”><a href=”#”>Contact</a></div>

<div class=”menubar”><a href=”#”>Register</a></div>

<div class=”menubar”><a href=”#”>Feedback</a></div>

</div>

<div id=”left” align=’center’>

Hello User

</div>

<div id=”right” align=’center’>

<center>

<p style=”font-size:24px; font-weight:bold; color:#FFFFFF;”>DETAILS</p>

</center>

<form >

<table id=login_table>

<tr>

<td>

<span id=login_text > Name:</span>

</td>

<td>

<input type=text id=name name=name><br>

</td>

</tr>

<tr>

<td>

<span id=login_text>Fname:</span>

</td>

<td>

<input type=text id=fname name=pass><br><br>

</td>

</tr>

<tr>

<td  colspan=’2′>

<center>

<a id=login_submit type=button name=submit value=”Submit”>Submit</a>

<br/>

<br/><a id=refresh type=button name=refresh value=”refresh”>refresh</a>

</center><br><br>

</td>

</tr>

</table>

</form>

</div>

</div>

<div id=”fourth”><center><span>Copyright &copy; <a href=”www.rightster.com”>Ravindra</a></center></div>

</body>

</html>

 

 

How to make the css and attach in view:-

  • firstelly create a folder name of data in root folder.
  • And now create a folder of css in data and in css folder create a css name of user1.css
  • And below link paste in html code .

<link href=”http://localhost/CodeIgniter/data/css/user1.css” type=”text/css” rel=”stylesheet” />

 

IN user1.css code here:-

body

{

background-color:#c7c5c5;

color:#fefefe;

font-family:Arial;

}

 

#main

{position:relative;

height:auto;

min-height:600px;

width:80%;

margin-left:10%;

margin-top:6%;

background-color:gray;

}

 

#first

{position:relative;

height:auto;

width:100%;

margin-top:10px;

background-color:gray;

font-size:45px;

color:#fefefe;

text-transform:capitalize;

 

}

 

#first span

{

height:60px;

font-size:45px;

margin-top:15px;

color:white;

text-transform:capitalize;

}

#second

{

height:60px;

background-color:#666666;

}

 

#menu

{

position:relative;

width:100%;

height:60px;

float:left;

background-color:#666666;

font-family:Arial;

}

 

#admin

{

height:60px;

float:left;

margin-left:100px;

background-color:#666666;

}

 

#admin a

{

color:white;

text-decoration:none;

}

.menubar

{

position:relative;

padding-top:20px;

background-color:#666666;

margin-left:10px;

padding-left:20px;

float:left;

color:white;

text-decoration:none;

font-size:20px;

font-family:Arial;

}

 

.menubar a

{

margin-left:10px;

color:white;

margin-top:10px;

text-decoration:none;

font-size:25px;

}

 

#third

{

height:auto;

font-size:18px;

margin-top:10px;

margin-left:0px;

color:white;

}

 

#left

{

height:auto;

width:600px;

font-size:18px;

margin-top:10px;

margin-left:0px;

color:white;

float:left;

}

 

#right

{

height:auto;

min-height:300px;

width:400px;

font-size:14px;

margin-top:10px;

margin-left:0px;

color:white;

float:right;

margin-right:6%;

border-radius:5px;

background-color:#5F5A59;

padding:10px;

}

#newMenu

{

height:auto;

width:900px;

font-size:20px;

margin-top:10px;

margin-left:0px;

color:white;

background-color:#5F5A59;

}

 

#newMenu a

{

color:white;

text-decoration:none;

padding-right:15px;

 

}

#fourth

{

height:auto;

width:80%;

margin-top:0px;

margin-left:10%;

clear:both;

background-color:gray;

}

#fourth span

{

font-size:15px;

margin-top:10px;

margin-left:10px;

color:white;

}

#login_input

{

width:180px;

height:25px;

border-radius:5px;

font-size:14px;

font-family:Arial;

background-color:#EEEEEE;

color:#444444;

//margin:0px;

}

#login_submit

{

 

width:100px;

height:30px;

font-family:Arial;

}

#register

{

height:auto;

width:600px;

font-size:18px;

margin-top:10px;

margin-left:0px;

color:white;

float:left;

margin-left:6%;

border-radius:5px;

background-color:#5F5A59;

}

#banner

{

font-size:45px;

font-family:georgia;

text-transform:capitalize;

}

 

 

How to set the starting controllers:-

  • codeigniter.com/application/config/routes.php
  • $route['default_controller'] = “ravi”;

 

How create a form in view:

 

<form action=”ravi/but” method=”post”>

<table id=login_table><tr><td>

<span id=login_text > Name:</span>

</td><td><input type=text id=name name=name><br>

</td></tr><tr><td>

<span id=login_text>Fname:</span>

</td><td><input type=text id=fname name=pass><br><br></td></tr><tr>

<td  colspan=’2′><center>

<input id=login_submit type=”submit” name=submit value=”Submit”>Submit</input>

<br/><br/><a id=refresh type=button name=refresh value=”refresh”>refresh</a>

</center><br><br></td></tr></table>

</form>

 

How to call a controller on button click:-

 

  • In above code we have created a form and a submit button in form.
  • And we have created a view button.php in view folder

 

<?php //if(isset($_GET(“submit”)))

//{

echo “hello button”;

//}

?>

  • And create a method in ravindra controller

public function but()

{ $this->load->view(‘button’);

}

  • And now we call the controller on a submit click from help of the form.

<form action=”ravi/but” method=”post”>

 

How to page redirect one to another:-

 

<a id=refresh type=button name=refresh value=”refresh” href=”test/index”>refresh</a>

  • In this test is a controller and index is a initial methode.

 

<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

class test extends CI_Controller {

public function index()

{        $this->load->view(‘testome’);

}

}

 

 

How to pass the value from controller and view:-

 

  • IN controller

 

public function index()

{

$data['name']=”ravindra”;

$data['sname']=”singh”;

$this->load->view(‘testome’,$data);

}

  • IN view

<?php  echo “your name is:-”.$name.” “.$sname;  ?>

 

or

<?php echo “your name is:-”.$name.” “.$sname; ?>

<?=$name ?> <?=$sname?>

 

 

How to pass the value from view and controller:-

 

How to create a database:-

  • Create a new database through phpmyadmin
  • Database name demo1
  • And create a table demo11
  • In demo11 have two fields name and fname.

 

– phpMyAdmin SQL Dump

– version 3.3.9

– http://www.phpmyadmin.net

– Host: localhost

– Generation Time: Jul 16, 2012 at 11:31 AM

– Server version: 5.5.8

– PHP Version: 5.3.5

 

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;

 

 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

 

– Database: `demo1`

 

– ——————————————————–

 

– Table structure for table `demo11`

 

CREATE TABLE IF NOT EXISTS `demo11` (

`Name` varchar(15) NOT NULL,

`Fname` varchar(15) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

 

How to configure Database:-

  • \CodeIgniter\application\config\database.php
  • $active_group = ‘default’;
  • $active_record = TRUE;
  • $db['default']['hostname'] = ‘localhost’;
  • $db['default']['username'] = ”;
  • $db['default']['password'] = ”;
  • $db['default']['database'] = ‘demo1′;
  • $db['default']['dbdriver'] = ‘mysql’;
  • $db['default']['dbprefix'] = ”;
  • $db['default']['pconnect'] = TRUE;
  • $db['default']['db_debug'] = TRUE;
  • $db['default']['cache_on'] = FALSE;
  • $db['default']['cachedir'] = ”;
  • $db['default']['char_set'] = ‘utf8′;
  • $db['default']['dbcollat'] = ‘utf8_general_ci’;
  • $db['default']['swap_pre'] = ”;
  • $db['default']['autoinit'] = TRUE;
  • $db['default']['stricton'] = FALSE;

 

 

How to Insert Data in  Database:-

 

How to select Data to Database:-

 

 

Examples:-

 

Some References Links:-

 

http://codeigniter.com/user_guide/general/controllers.html

 

http://codeigniter.com/tutorials/watch/intro/

 

http://codeigniter.com/tutorials/watch/blog/

http://henrihnr.wordpress.com/2009/04/26/simple-crud-application/

 

CakePhp

http://book.cakephp.org/1.3/view/1554/Appendices

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>