Step 01
Download the latest version of codeigniter 3.0.
http://www.codeigniter.com/download
Step 02
Put it in www folder in WAMP or any other relavant folder in your server.
Step 03
http://localhost/codeigniter/index.php and you will see the basic default interface of CI.
Step 04
Before stating coding create a datasase called student_database and a table called student_details.
Add some data into it.
image here.
Step 05
Now download bootstrap and put it in root directory /Codeigniter
http://getbootstrap.com/
Step 06
Do the relavant modifications in database.PHP
Step 07
Now is is the time to start the codeing
First we need to create the header footer and the template.php in application\views\includes_user directory
N.B includes_user have to create.
Create header.php
<script src="<?php echo base_url('bootstrap/js/bootstrap.js'); ?>"></script>
<script src="<?php echo base_url('bootstrap/jquery-2.1.4.min.js'); ?>"></script>
<script src="<?php echo base_url('bootstrap/jquery-2.1.4.js'); ?>"></script> <!-- jQuery -->
<!-- Stylesheets -->
<link href="<?php echo base_url('bootstrap/css/bootstrap.css'); ?>" rel="stylesheet">
Create footer.php
<?php echo("This is footer"); ?>
Create template.php
<?php
ob_start();
if(!isset($_SESSION)){
session_start();
}
?>
<?php $this->load->view('includes_user/header'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('includes_user/footer'); ?>
Step08
*Now config autoload url,form heplers and session,database,form_validation library in autoload.php.
Step 09
Download https://jquery.com/download/ and put it inside the bootstrap folder.
Step 09.
Create the controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start();
//This starts the color Controller.
class student extends CI_Controller
{
//This is index function.
public function index()
{
$data['main_content'] ='student/student_view';
$this->load->view('includes_user/template.php',$data);
}
//This is validate function.
public function validate($action='',$cus_id='')
{
// print_r($this->input->post('action'));die();
$this->form_validation->set_error_delimiters('<div >','</div>');
if($this->input->post('action')=='Add'|| $this->input->post('action')=='Edit'|| $this->input->post('action')=='Delete')
{
if($this->input->post('action')=='Add'){
$this->form_validation->set_rules('StudentId', 'Student ID', 'trim|required|is_unique[student_details.StudentId]');
}else{
$this->form_validation->set_rules('StudentId', 'Student ID', 'trim|required');
}
$this->form_validation->set_rules('Name', 'Student Name', 'trim|required');
if($this->form_validation->run()== FALSE)
{
switch($this->input->post('action'))
{
case 'Add':
$this->add();
break;
case 'Edit':
$this->edit($this->input->post('ID'));
break;
case 'Delete':
$this->delete($this->input->post('ID'));
break;
}
}else
{
switch($this->input->post('action')){
case 'Add':
$this->create();
break;
case 'Edit':
$this->update();
break;
case 'Delete':
$this->remove();
break;
case 'View':
$this->index();
break;
}
}
}
}
//This is insert function.
function add()
{
$data = $this->load_data();
$data['action'] = 'Add';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is view function.
public function view($id='')
{
//print_r($id);die();
$data = $this->load_data($id);
$data['action'] = 'View';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is edit function.
public function edit($id='')
{
$data = $this->load_data($id);
$data['action'] = 'Edit';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is delete function.
public function delete($id='')
{
$data = $this->load_data($id);
$data['action'] = 'Delete';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is get_all_data function.
public function get_all_data()
{
$this->load->model('student_model');
$data['records'] = $this->student_model->get_all_student_details($this->input->post('studentid'));
$this->load->view('student/students_srch_res',$data);
}
//This is load_data function.
public function load_data($id='')
{
$this->load->model('student_model');
$data['details'] = $this->student_model->get_student_id($id);
return $data;
}
//This is create function.
public function create()
{
$this->load->model('student_model');
if($this->student_model->add($this->input->post())){
$this->session->set_flashdata('warn',RECORD_ADD);
redirect('student');
}
else
{
$this->session->set_flashdata('warn',ERROR);
redirect('student');
}
}
//This is update function.
public function update()
{
$this->load->model('student_model');
$this->student_model->edit($this->input->post());
$this->session->set_flashdata('warn',RECORD_UPDATE);
redirect('student/index/'.$this->input->post('ID'));
}
//This is remove function.
public function remove()
{
$this->load->model('student_model');
$this->student_model->delete($this->input->post());
$this->session->set_flashdata('warn',RECORD_DELETE);
redirect('student/index/'.$this->input->post('ID'));
}
}
?>
Step 10 Create Model.
<?php
/**
* 2015 FEB: Ujitha marks that this is the begining of the model color_Model.
* */
class student_model extends CI_Model
{
/**
* 2015 FEB: Ujitha selects all brands from the table m001_02vehicle_color.
* @param string brandid
* @return array standard class object
* */
public function get_all_student_details($id='')
{
$this->db->select('*');
$this->db->from('student_details');
if($id!='')
{
$this->db->like('StudentId',$id);
}
$result = $this->db->get()->result();
return $result;
}
/**
* 2015 FEB: Ujitha insert all brands to the the table m001_02vehicle_color.
* @param associative array.
* @return nothing.
* */
public function add($data)
{
$data=array(
'StudentId' => $this->input->post('StudentId'),
'Name' => $this->input->post('Name'),
);
$this->db->insert('student_details',$data);
$this->session->set_flashdata('warn',RECORD_ADD);
redirect("student/index");
}
/**
* 2015 FEB: Ujitha edit the data from the table m001_02vehicle_color.
* @param associative array.
* @return boolean.
* */
public function edit($data='')
{
$id = $this->input->post('ID');
$dataset=array(
'StudentId' => $this->input->post('StudentId'),
'Name' => $this->input->post('Name'),
'Mobile' => 'oiil',
);
$this->db->where('ID',$id);
$this->db->update('student_details',$dataset);
}
/**
* 2015 FEB: Ujitha delete the data from the table m001_00vehicle_brand.
* @return boolean.
* */
public function delete()
{
$id = $this->input->post('ID');
$this->db->delete('student_details', array('id' =>$id));
}
/**
* 2015 FEB: Ujitha get the selected brandid from the table m001_02vehicle_color.
* @param string brandid.
* @return multidimensional array.
* */
public function get_student_id($id='')
{
$this->db->select('*');
$this->db->from('student_details');
$this->db->where('ID',$id);
$query = $this->db->get();
return $query->result_array();
}
public function gt_color_name($id='')
{
$this->db->select('color');
$this->db->from(VEH_COLOR);
$this->db->where('id',$id);
$query = $this->db->get();
return $query->result();
}
}
Create three views.
a. student_view.php
<script >
jQuery(document).ready(function(){
get_results();
jQuery('#searchform').submit(function(event){
event.preventDefault();
get_results();
});
jQuery('#searchform').change(function(){
event.preventDefault();
get_results();
});
jQuery('#searchform').keyup(function(){
event.preventDefault();
get_results();
});
function get_results(){
jQuery.ajax({
url : '<?php echo site_url('student/get_all_data')?>',
type: 'post',
data : jQuery('#searchform').serializeArray(),
success : function(msg){
// alert("kkkk");
jQuery('#result-content').html(msg);
},
error: function (){ alert('Error'); }
});
}
});
</script>
<div >
<!-- Page heading -->
<div >
<div >
<h2 ><i ></i> <?php echo("Student Data")?></h2>
</div>
<div ></div>
</div>
<!-- Page heading ends -->
<br>
<!-- Matter -->
<div >
<div >
<div >
<?php if($this->session->flashdata('warn') != ''){ ?>
<script>jQuery(document).ready(function(){jQuery('.alert').delay(4000).slideUp(1000);});</script>
<div >
<?php echo $this->session->flashdata('warn'); ?>
</div>
<?php }?>
</div>
</div>
<div >
<div >
<br />
<!-- Form starts -->
<?php echo form_open('student/get_all_data',' id="searchform"');
$attr = array( 'class' => 'col-lg-2 control-label' ); ?>
<div >
<?php echo form_label("Student ID", 'studentid', $attr); ?>
<div >
<?php echo form_input('studentid',set_value('studentid'),' id="studentid"'); ?>
</div>
</div>
<div >
<div >
<button ><i ></i> <?php echo ('search')?></button>
<button ><i ></i> <?php echo ('reset')?></button>
<?php echo '<a href="'.site_url('student/add').'" ><i ></i> '.'Add new'.'</a>'; ?>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
<br>
<div id="result-content"></div>
</div>
<!-- Matter ends -->
</div>
<!-- Mainbar ends -->
b. students_srch_res.php
<?php $CI =& get_instance();
?>
<div >
<div >
<div >
<div >
<div >
<div >
<div >
<!-- Table Page -->
<div >
<!-- Table -->
<div >
<table cellpadding="0" cellspacing="0" border="0" id="data-table" width="100%">
<thead>
<tr>
<th><?php echo ('ID');?></th>
<th><?php echo ('Student ID');?></th>
<th><?php echo ('Name');?></th>
<th><?php echo ('Mobile');?></th>
<th><?php echo ('Options');?></th>
</tr>
</tr>
</thead>
<tbody>
<?php foreach($records as $record): {}?>
<tr>
<td><?php echo $record->ID; ?></td>
<td><?php echo $record->StudentId; ?></td>
<td><?php echo $record->Name; ?></td>
<td><?php echo $record->Mobile; ?></td>
<td>
<a href="<?php echo site_url("student/view/".trim($record->ID)."") ?>" >Search </a>
<a href="<?php echo site_url("student/edit/".trim($record->ID)."") ?>" >Edit </a>
<a href="<?php echo site_url("student/delete/".trim($record->ID)."") ?>" >Delete </a>
</td>
<?php endforeach ?>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<div ></div>
</div>
</div>
</div>
</div>
<div >
<!-- Footer goes here -->
</div>
</div>
</div>
</div>
</div>
</div>
<script >
jQuery('#data-table').dataTable({
"sPaginationType": "full_numbers",
"bFilter": false,
"oLanguage": {
"sUrl": "<?php echo base_url('datatable_language'); ?>"
}
});
</script>
c. manage_student.php
<?php $CI =& get_instance();
$result = array('StudentId' => '','Name'=>'','color'=>'','ID'=>'');
switch($action){
case 'Add':
$heading = $CI->lang->line('add');
$dis = '';
$view = '';
$o_dis = '';
break;
case 'Edit':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('edit');
$dis = 'readonly';
$view = '';
$o_dis = '';
break;
case 'Delete':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('delete');
$dis = 'readonly';
$view = '';
$o_dis = '';
break;
case 'View':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('view');
$view = '';
$dis = 'readonly';
$o_dis = 'disabled';
break;
}
?>
<div >
<!-- Page heading -->
<div >
<div >
<h3 ><i ></i> <?php echo $action." ".'Student'?> </h3>
</div>
</div>
<!-- Page heading ends -->
<!-- Matter -->
<div >
<div >
<div >
<br />
<!-- Form starts -->
<?php $id=$result['ID'];?>
<?php echo form_open('student/validate/'.$id.'/'.$action,''); $attr = array('class' => 'col-lg-2 control-label'); ?>
<?php if($this->session->flashdata('warn') != ''){ ?>
<script>jQuery(document).ready(function(){jQuery('.alert').delay(4000).slideUp(1000);});</script>
<div >
<?php echo $this->session->flashdata('warn')?>
</div>
<?php }?>
<div >
<?php echo form_label('Student ID', 'id', $attr); ?>
<div >
<?php if($action == 'Edit'){ ?>
<?php echo form_input('StudentId',set_value('StudentId',$result['StudentId']),' id="StudentId" '.$dis); ?>
<?php echo form_error('StudentId'); ?>
<?php }else{?>
<?php echo form_input('StudentId',set_value('StudentId',$result['StudentId']),' id="StudentId" '.$o_dis); ?>
<?php echo form_error('StudentId'); ?>
<?php }?>
</div>
</div>
<div >
<?php echo form_label('Name', 'name', $attr); ?>
<div >
<?php echo form_input('Name',set_value('Name',$result['Name']),' id="Name" '.$o_dis); ?>
<?php echo form_error('Name'); ?>
</div>
</div>
</div>
</div>
</div>
<div >
<div >
<?php if($action != 'View'){?>
<?php echo form_hidden('ID',$id); ?>
<?php echo form_hidden('action',$action); ?>
<?php echo form_submit('submit',strtolower($action) ,''); ?>
<?php echo form_reset('reset','reset','class = "btn btn-sm btn-default"'); ?>
<?php }else{
echo form_hidden('action',$action);
echo anchor(site_url('student'),'ok','');
} ?>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
<!-- Matter ends -->
</div>
<!-- Mainbar ends -->
Step 13.
That is it enjoy the coding...
http://localhost/Codeigniter/index.php/student/index
Download the latest version of codeigniter 3.0.
http://www.codeigniter.com/download
Step 02
Put it in www folder in WAMP or any other relavant folder in your server.
Step 03
http://localhost/codeigniter/index.php and you will see the basic default interface of CI.
Step 04
Before stating coding create a datasase called student_database and a table called student_details.
Add some data into it.
image here.
Step 05
Now download bootstrap and put it in root directory /Codeigniter
http://getbootstrap.com/
Step 06
Do the relavant modifications in database.PHP
Step 07
Now is is the time to start the codeing
First we need to create the header footer and the template.php in application\views\includes_user directory
N.B includes_user have to create.
Create header.php
<script src="<?php echo base_url('bootstrap/js/bootstrap.js'); ?>"></script>
<script src="<?php echo base_url('bootstrap/jquery-2.1.4.min.js'); ?>"></script>
<script src="<?php echo base_url('bootstrap/jquery-2.1.4.js'); ?>"></script> <!-- jQuery -->
<!-- Stylesheets -->
<link href="<?php echo base_url('bootstrap/css/bootstrap.css'); ?>" rel="stylesheet">
Create footer.php
<?php echo("This is footer"); ?>
Create template.php
<?php
ob_start();
if(!isset($_SESSION)){
session_start();
}
?>
<?php $this->load->view('includes_user/header'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('includes_user/footer'); ?>
Step08
*Now config autoload url,form heplers and session,database,form_validation library in autoload.php.
Step 09
Download https://jquery.com/download/ and put it inside the bootstrap folder.
Step 09.
Create the controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start();
//This starts the color Controller.
class student extends CI_Controller
{
//This is index function.
public function index()
{
$data['main_content'] ='student/student_view';
$this->load->view('includes_user/template.php',$data);
}
//This is validate function.
public function validate($action='',$cus_id='')
{
// print_r($this->input->post('action'));die();
$this->form_validation->set_error_delimiters('<div >','</div>');
if($this->input->post('action')=='Add'|| $this->input->post('action')=='Edit'|| $this->input->post('action')=='Delete')
{
if($this->input->post('action')=='Add'){
$this->form_validation->set_rules('StudentId', 'Student ID', 'trim|required|is_unique[student_details.StudentId]');
}else{
$this->form_validation->set_rules('StudentId', 'Student ID', 'trim|required');
}
$this->form_validation->set_rules('Name', 'Student Name', 'trim|required');
if($this->form_validation->run()== FALSE)
{
switch($this->input->post('action'))
{
case 'Add':
$this->add();
break;
case 'Edit':
$this->edit($this->input->post('ID'));
break;
case 'Delete':
$this->delete($this->input->post('ID'));
break;
}
}else
{
switch($this->input->post('action')){
case 'Add':
$this->create();
break;
case 'Edit':
$this->update();
break;
case 'Delete':
$this->remove();
break;
case 'View':
$this->index();
break;
}
}
}
}
//This is insert function.
function add()
{
$data = $this->load_data();
$data['action'] = 'Add';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is view function.
public function view($id='')
{
//print_r($id);die();
$data = $this->load_data($id);
$data['action'] = 'View';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is edit function.
public function edit($id='')
{
$data = $this->load_data($id);
$data['action'] = 'Edit';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is delete function.
public function delete($id='')
{
$data = $this->load_data($id);
$data['action'] = 'Delete';
$data['main_content'] = 'student/manage_student';
$this->load->view('includes_user/template.php',$data);
}
//This is get_all_data function.
public function get_all_data()
{
$this->load->model('student_model');
$data['records'] = $this->student_model->get_all_student_details($this->input->post('studentid'));
$this->load->view('student/students_srch_res',$data);
}
//This is load_data function.
public function load_data($id='')
{
$this->load->model('student_model');
$data['details'] = $this->student_model->get_student_id($id);
return $data;
}
//This is create function.
public function create()
{
$this->load->model('student_model');
if($this->student_model->add($this->input->post())){
$this->session->set_flashdata('warn',RECORD_ADD);
redirect('student');
}
else
{
$this->session->set_flashdata('warn',ERROR);
redirect('student');
}
}
//This is update function.
public function update()
{
$this->load->model('student_model');
$this->student_model->edit($this->input->post());
$this->session->set_flashdata('warn',RECORD_UPDATE);
redirect('student/index/'.$this->input->post('ID'));
}
//This is remove function.
public function remove()
{
$this->load->model('student_model');
$this->student_model->delete($this->input->post());
$this->session->set_flashdata('warn',RECORD_DELETE);
redirect('student/index/'.$this->input->post('ID'));
}
}
?>
Step 10 Create Model.
<?php
/**
* 2015 FEB: Ujitha marks that this is the begining of the model color_Model.
* */
class student_model extends CI_Model
{
/**
* 2015 FEB: Ujitha selects all brands from the table m001_02vehicle_color.
* @param string brandid
* @return array standard class object
* */
public function get_all_student_details($id='')
{
$this->db->select('*');
$this->db->from('student_details');
if($id!='')
{
$this->db->like('StudentId',$id);
}
$result = $this->db->get()->result();
return $result;
}
/**
* 2015 FEB: Ujitha insert all brands to the the table m001_02vehicle_color.
* @param associative array.
* @return nothing.
* */
public function add($data)
{
$data=array(
'StudentId' => $this->input->post('StudentId'),
'Name' => $this->input->post('Name'),
);
$this->db->insert('student_details',$data);
$this->session->set_flashdata('warn',RECORD_ADD);
redirect("student/index");
}
/**
* 2015 FEB: Ujitha edit the data from the table m001_02vehicle_color.
* @param associative array.
* @return boolean.
* */
public function edit($data='')
{
$id = $this->input->post('ID');
$dataset=array(
'StudentId' => $this->input->post('StudentId'),
'Name' => $this->input->post('Name'),
'Mobile' => 'oiil',
);
$this->db->where('ID',$id);
$this->db->update('student_details',$dataset);
}
/**
* 2015 FEB: Ujitha delete the data from the table m001_00vehicle_brand.
* @return boolean.
* */
public function delete()
{
$id = $this->input->post('ID');
$this->db->delete('student_details', array('id' =>$id));
}
/**
* 2015 FEB: Ujitha get the selected brandid from the table m001_02vehicle_color.
* @param string brandid.
* @return multidimensional array.
* */
public function get_student_id($id='')
{
$this->db->select('*');
$this->db->from('student_details');
$this->db->where('ID',$id);
$query = $this->db->get();
return $query->result_array();
}
public function gt_color_name($id='')
{
$this->db->select('color');
$this->db->from(VEH_COLOR);
$this->db->where('id',$id);
$query = $this->db->get();
return $query->result();
}
}
Create three views.
a. student_view.php
<script >
jQuery(document).ready(function(){
get_results();
jQuery('#searchform').submit(function(event){
event.preventDefault();
get_results();
});
jQuery('#searchform').change(function(){
event.preventDefault();
get_results();
});
jQuery('#searchform').keyup(function(){
event.preventDefault();
get_results();
});
function get_results(){
jQuery.ajax({
url : '<?php echo site_url('student/get_all_data')?>',
type: 'post',
data : jQuery('#searchform').serializeArray(),
success : function(msg){
// alert("kkkk");
jQuery('#result-content').html(msg);
},
error: function (){ alert('Error'); }
});
}
});
</script>
<div >
<!-- Page heading -->
<div >
<div >
<h2 ><i ></i> <?php echo("Student Data")?></h2>
</div>
<div ></div>
</div>
<!-- Page heading ends -->
<br>
<!-- Matter -->
<div >
<div >
<div >
<?php if($this->session->flashdata('warn') != ''){ ?>
<script>jQuery(document).ready(function(){jQuery('.alert').delay(4000).slideUp(1000);});</script>
<div >
<?php echo $this->session->flashdata('warn'); ?>
</div>
<?php }?>
</div>
</div>
<div >
<div >
<br />
<!-- Form starts -->
<?php echo form_open('student/get_all_data',' id="searchform"');
$attr = array( 'class' => 'col-lg-2 control-label' ); ?>
<div >
<?php echo form_label("Student ID", 'studentid', $attr); ?>
<div >
<?php echo form_input('studentid',set_value('studentid'),' id="studentid"'); ?>
</div>
</div>
<div >
<div >
<button ><i ></i> <?php echo ('search')?></button>
<button ><i ></i> <?php echo ('reset')?></button>
<?php echo '<a href="'.site_url('student/add').'" ><i ></i> '.'Add new'.'</a>'; ?>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
<br>
<div id="result-content"></div>
</div>
<!-- Matter ends -->
</div>
<!-- Mainbar ends -->
b. students_srch_res.php
<?php $CI =& get_instance();
?>
<div >
<div >
<div >
<div >
<div >
<div >
<div >
<!-- Table Page -->
<div >
<!-- Table -->
<div >
<table cellpadding="0" cellspacing="0" border="0" id="data-table" width="100%">
<thead>
<tr>
<th><?php echo ('ID');?></th>
<th><?php echo ('Student ID');?></th>
<th><?php echo ('Name');?></th>
<th><?php echo ('Mobile');?></th>
<th><?php echo ('Options');?></th>
</tr>
</tr>
</thead>
<tbody>
<?php foreach($records as $record): {}?>
<tr>
<td><?php echo $record->ID; ?></td>
<td><?php echo $record->StudentId; ?></td>
<td><?php echo $record->Name; ?></td>
<td><?php echo $record->Mobile; ?></td>
<td>
<a href="<?php echo site_url("student/view/".trim($record->ID)."") ?>" >Search </a>
<a href="<?php echo site_url("student/edit/".trim($record->ID)."") ?>" >Edit </a>
<a href="<?php echo site_url("student/delete/".trim($record->ID)."") ?>" >Delete </a>
</td>
<?php endforeach ?>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<div ></div>
</div>
</div>
</div>
</div>
<div >
<!-- Footer goes here -->
</div>
</div>
</div>
</div>
</div>
</div>
<script >
jQuery('#data-table').dataTable({
"sPaginationType": "full_numbers",
"bFilter": false,
"oLanguage": {
"sUrl": "<?php echo base_url('datatable_language'); ?>"
}
});
</script>
c. manage_student.php
<?php $CI =& get_instance();
$result = array('StudentId' => '','Name'=>'','color'=>'','ID'=>'');
switch($action){
case 'Add':
$heading = $CI->lang->line('add');
$dis = '';
$view = '';
$o_dis = '';
break;
case 'Edit':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('edit');
$dis = 'readonly';
$view = '';
$o_dis = '';
break;
case 'Delete':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('delete');
$dis = 'readonly';
$view = '';
$o_dis = '';
break;
case 'View':
if(!empty($details[0])){$result= $details[0];}
$heading = $CI->lang->line('view');
$view = '';
$dis = 'readonly';
$o_dis = 'disabled';
break;
}
?>
<div >
<!-- Page heading -->
<div >
<div >
<h3 ><i ></i> <?php echo $action." ".'Student'?> </h3>
</div>
</div>
<!-- Page heading ends -->
<!-- Matter -->
<div >
<div >
<div >
<br />
<!-- Form starts -->
<?php $id=$result['ID'];?>
<?php echo form_open('student/validate/'.$id.'/'.$action,''); $attr = array('class' => 'col-lg-2 control-label'); ?>
<?php if($this->session->flashdata('warn') != ''){ ?>
<script>jQuery(document).ready(function(){jQuery('.alert').delay(4000).slideUp(1000);});</script>
<div >
<?php echo $this->session->flashdata('warn')?>
</div>
<?php }?>
<div >
<?php echo form_label('Student ID', 'id', $attr); ?>
<div >
<?php if($action == 'Edit'){ ?>
<?php echo form_input('StudentId',set_value('StudentId',$result['StudentId']),' id="StudentId" '.$dis); ?>
<?php echo form_error('StudentId'); ?>
<?php }else{?>
<?php echo form_input('StudentId',set_value('StudentId',$result['StudentId']),' id="StudentId" '.$o_dis); ?>
<?php echo form_error('StudentId'); ?>
<?php }?>
</div>
</div>
<div >
<?php echo form_label('Name', 'name', $attr); ?>
<div >
<?php echo form_input('Name',set_value('Name',$result['Name']),' id="Name" '.$o_dis); ?>
<?php echo form_error('Name'); ?>
</div>
</div>
</div>
</div>
</div>
<div >
<div >
<?php if($action != 'View'){?>
<?php echo form_hidden('ID',$id); ?>
<?php echo form_hidden('action',$action); ?>
<?php echo form_submit('submit',strtolower($action) ,''); ?>
<?php echo form_reset('reset','reset','class = "btn btn-sm btn-default"'); ?>
<?php }else{
echo form_hidden('action',$action);
echo anchor(site_url('student'),'ok','');
} ?>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
<!-- Matter ends -->
</div>
<!-- Mainbar ends -->
Step 13.
That is it enjoy the coding...
http://localhost/Codeigniter/index.php/student/index