base.php(controller folder) :
<?php
class base extends CI_Controller {
function __construct() /*loading constructor*/
{
parent::__construct();
}
function you()
{
$data['name']=$this->name;
$data['color']=$this->color;
}
public function getall() /*loading model*/
{
$this->load->model('empl');
$data['query']=$this->empl->employeey(); //loading model function
}
public function index()
{
$pageinfo['title']="this is my title";
$pageinfo['heading']="MY HEADING";
$this->load->view('base_view',$pageinfo);
$this->getall();
}
}
?>
empl.php(model folder)
<?php
class empl extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('table');
}
function employeey()
{
$tmpl = array (
'table_open' => '<table border="1" cellpadding="4" cellspacing="1" width="30%"
align="center" bordercolor="#CCCCCC">',
'row_alt_start' => '<tr bgcolor="lightgrey" >',
);
$this->table->set_template($tmpl);
//$this->db->where('id','3'); //used for where condition
$query=$this->db->get('sample'); //used for selecting all the values
$header = array('emp id', 'first name');
$this->table->set_heading($header);
echo $this->table->generate($query);
}
}
?>
base_view.php(view folder)
create one file name base_view.php in view folder for displaying contents
Database
use database name sample
set fields-> id(int(4)), name(varchar(50))
in attachment does not contain database u want to create it by using previous instructions
Download
No comments:
Post a Comment