Seach

how to retrive data from database using codeigniter 1

1)download and extract codeigniter to wamp folder
2)open application/config/database.php then change the following
$db['default']['hostname'] = 'your hostname';
$db['default']['username'] = ''your mysql user name";
$db['default']['password'] = ''your mysql password";
$db['default']['database'] = 'your database name';
3)open config folder under that config.php then add
$config['index_page'] = 'index.php'; //this is the page loaded when you press the folder
4)create 3 files under controller,model.view
under controller create Blog.php,under model Blog_model.php,under view create
Blog_view.php

Blog.php

<?php
class Blog extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Blog_model');//used to load the model class
       
    }
   
    public function index()
    {
        $data['query']=$this->Blog_model->getall();//used to call model function
       
if(count($data)>0)
      
        {
                $this->load->view('Blog_view',$data);//used to call view class
       
        }
        else
        {
            echo 'nothing to show';
            exit();
        }
    }
   
}

?>