title: call a controller function in codeigniter
body: <p>i ' m still a beginner in codeigniter and i want to call a function of a controller but i don't know why i always get <code>404 error</code></p>
  
  <p><strong>Error:</strong>
  <a href="https://i.stack.imgur.com/Xlydv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xlydv.png" alt="error"></a></p>
  
  <p>this is the view code  </p>
  
  <pre><code>&lt;?php foreach ($records  as $new_Employee):
      ?&gt;
      &lt;form class="form-horizontal"    ?&gt;
                  &lt;div class="col-lg-5"&gt;
                      &lt;div class="media"&gt;
                          &lt;a class="pull-left" href="#"&gt;
                              &lt;img class="media-object dp img-circle"  src="../assets/img/avatar5.png" style="width: 100px;height:100px;"&gt;
                          &lt;/a&gt;
                          &lt;div class="media-body"&gt;
                              &lt;h4 class="media-heading"&gt; &lt;?php echo $new_Employee["name_Employee"]; ?&gt; &lt;small&gt; &lt;?php echo $new_Employee["nationality_Employee"]; ?&gt;&lt;/small&gt;&lt;/h4&gt;
                              &lt;h5&gt;&lt;?php echo $new_Employee["email"]; ?&gt; &lt;/h5&gt;
                              &lt;hr style="margin:8px auto"&gt;
                              &lt;table cellpadding="50px"&gt;
                                  &lt;tr&gt;
                             &lt;td&gt; &lt;p data-placement="top" data-toggle="tooltip" title="Edit"&gt;&lt;button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" &gt;&lt;span class="glyphicon glyphicon-pencil"&gt;&lt;/span&gt;&lt;/button&gt;&lt;/p&gt;&lt;/td&gt;
                             &lt;td&gt;  &lt;p data-placement="top" data-toggle="tooltip" title="Delete"&gt;&lt;button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete"   &gt;&lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;&lt;/button&gt;&lt;/p&gt;&lt;/td&gt;
                                &lt;td&gt; &lt;a class="btn btn-danger" href="&lt;?php echo site_url('PdgDashboard/deleteEmployee'.$new_Employee['name_Employee']);  ?&gt;"&gt;&lt;/a&gt;&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/table&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
  
      &lt;/form&gt;
  &lt;?php
  endforeach; ?&gt;
  </code></pre>
  
  <p>this is the  controller that  i  called  </p>
  
  <pre><code> class PdgDashboard extends CI_Controller {
       public function index($data)
  {
      $data['pseudo_Empoyee'] = $data['new_Employee']['pseudo_Empoyee'];
      $data['nationality_Employee'] = $data['new_Employee']['nationality_Employee'];
      $data['tel_Employee'] = $data['new_Employee']['tel_Employee'];
      $this-&gt;load-&gt;view('Template/Pdg_Default_Page');
  
  
  }
  
  
       public function __construct()
       {
           parent::__construct();
           $this-&gt;load-&gt;model('employee');
           $this-&gt;load-&gt;helper('url_helper');
           $this-&gt;load-&gt;model('absence');
           $this-&gt;load-&gt;model('lieve');
  
       }
  
       public function EmployeeMang( ){
  $this-&gt;load-&gt;library('pagination');
           $config["base_url"]="http://localhost/GRH/PdgDashboard/EmployeeMang";
           $config['total_rows'] =$this-&gt;db-&gt;get("cs_employee")-&gt;num_rows();
           $config['per_page'] =3;
           $config['num_links'] = 10;
           $this-&gt;pagination-&gt;initialize($config);
           $data['records']=$this-&gt;db-&gt;select('*')-&gt;get('cs_employee', $config['per_page'],$this-&gt;uri-&gt;segment(3))-&gt;result_array();
  
           $data['links']  = $this-&gt;pagination-&gt;create_links();
  
           $this-&gt;load-&gt;view('pages/Employee_Manag', $data);
              /* $data['new_Employee'] = $this-&gt;employee-&gt;get_Employee();
               if (empty($data['new_Employee']))
               {
                   show_404();
               }
  
  
           $this-&gt;load-&gt;view('pages/Employee_Manag', $data);
  
        //   $this-&gt;load-&gt;view('pages/Employee_Manag', $data);*/
  
       }
       public  function searchEmployee(){
           if($this-&gt;input-&gt;post('search')!="")
           {
           $this-&gt;load-&gt;library('pagination');
           $confi["base_url"]="http://localhost/GRH/PdgDashboard/searchEmployee";
  
           $confi['per_page'] =3;
           $confi['num_links'] = 10;
           $this-&gt;pagination-&gt;initialize($confi);
  
           $search_term = $this-&gt;input-&gt;post('search');
           $data['rec']= $this-&gt;db-&gt;where('name_Employee',$search_term)-&gt;get('cs_employee', $confi['per_page'],$this-&gt;uri-&gt;segment(3))-&gt;result_array();
           $config['total_rows'] = sizeof($data['rec']);
           // Use a model to retrieve the results.
      //     $data['rec'] = $this-&gt;employee-&gt;searchEmployee($search_term);
  
           // Pass the results to the view.
           $data['link']  = $this-&gt;pagination-&gt;create_links();
           $this-&gt;load-&gt;view('pages/search', $data);}
           else
               $this-&gt;EmployeeMang();
       }
  public  function createEmployee(){
  
      $this-&gt;load-&gt;helper('form');
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('txtFirstName', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtLastName', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtCin', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('date', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('ComboCountry', 'Text', 'required');
  
      $this-&gt;form_validation-&gt;set_rules('txtEmail', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtphone', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtAddress', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtPostal', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('Training', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('Startdate', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('txtBank', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('comboStatus', 'Text', 'required');
      $this-&gt;form_validation-&gt;set_rules('Startdate', 'Text', 'required');
  
  
  
  
      $this-&gt;employee-&gt;createEmployee();
      $data['new_Employee'] = $this-&gt;employee-&gt;get_Employee();
  
      $this-&gt;EmployeeMang();
      //TODO link between data base and form keys
  
  
  }
  
       public function deleteEmployee($EmployeeName){
      $this-&gt;load-&gt;model('employee');
    $this-&gt;emloyee-&gt;deleteEmployee($EmployeeName);
        $this-&gt;EmployeeMang();
       }
       public function PayoutRequest(){
  
           $this-&gt;load-&gt;view('pages/Advance_Payment_Reques');
  
  
       }
       public function  Recruitement(){
  
           $this-&gt;load-&gt;view('pages/Recruitement');
  
  
       }
       public function Announce(){
  
           $this-&gt;load-&gt;view('pages/announcement');
  
       }
       public function Holiday_Requests(){
  
           $this-&gt;load-&gt;view('pages/HolidaysPosts');
  
       }
  
       public function absence(){
  
           $this-&gt;load-&gt;view('pages/AbsenceConsult');
  
       }
       public function Leave_Requests(){
  
           $this-&gt;load-&gt;view('pages/Leave_Requests');
  
  
       }
       public function Profile_Employee(){
  
           $this-&gt;load-&gt;view('pages/Profile_Employee');
  
       }
  
     public function Post_Managment(){
  
         $this-&gt;load-&gt;view('pages/Post_Managment');
  
  
     }
  
       public function displayAbsence(){
           $this-&gt;load-&gt;library('pagination');
           $config["base_url"]="http://localhost/GRH/PdgDashboard/displayAbsence";
           $config['total_rows']=sizeof($this-&gt;absence-&gt;getAbsence());
           $config['per_page'] =3;
           $config['num_links'] = 3;
           $this-&gt;pagination-&gt;initialize($config);
           $data['records']=$this-&gt;db-&gt;select('*')-&gt;get('cs_absence', $config['per_page'],$this-&gt;uri-&gt;segment(3))-&gt;result_array();
  
           $data['links']  = $this-&gt;pagination-&gt;create_links();
  
           $this-&gt;load-&gt;view('pages/AbsenceConsult', $data);
  
       }
  
    public function   searchAbcense()
    {   $search_term = $this-&gt;input-&gt;post('search');
        if($search_term!="") {
            $this-&gt;load-&gt;library('pagination');
            $confi["base_url"] = "http://localhost/GRH/PdgDashboard/ searchAbcense";
  
            $confi['per_page'] = 3;
            $confi['num_links'] = 10;
            $this-&gt;pagination-&gt;initialize($confi);
  
  
            $data['records'] = $this-&gt;db-&gt;where('id_Employee_absence', $search_term)-&gt;get('cs_absence', $confi['per_page'], $this-&gt;uri-&gt;segment(3))-&gt;result_array();
            $config['total_rows'] = sizeof($data['records']);
            // Use a model to retrieve the results.
            //     $data['rec'] = $this-&gt;employee-&gt;searchEmployee($search_term);
  
            // Pass the results to the view.
            $data['links'] = $this-&gt;pagination-&gt;create_links();
            $this-&gt;load-&gt;view('pages/AbsenceConsult', $data);
        }
        else $this-&gt;displayAbsence();
  
   }
  
       public function displayLieve(){
           $this-&gt;load-&gt;library('pagination');
           $config["base_url"]="http://localhost/GRH/PdgDashboard/displayLieve";
           $config['total_rows']=sizeof($this-&gt;lieve-&gt;getLieve());
           $config['per_page'] =3;
           $config['num_links'] = 3;
           $this-&gt;pagination-&gt;initialize($config);
           $data['records']=$this-&gt;db-&gt;select('*')-&gt;get('cs_lieve', $config['per_page'],$this-&gt;uri-&gt;segment(3))-&gt;result_array();
  
           $data['links']  = $this-&gt;pagination-&gt;create_links();
  
           $this-&gt;load-&gt;view('pages/HolidaysPosts', $data);
  
       }
  
  
       public function   searcLieve()
       {   $search_term = $this-&gt;input-&gt;post('search');
           if($search_term!="") {
               $this-&gt;load-&gt;library('pagination');
               $confi["base_url"] = "http://localhost/GRH/PdgDashboard/searcLieve";
  
               $confi['per_page'] = 3;
               $confi['num_links'] = 10;
               $this-&gt;pagination-&gt;initialize($confi);
  
  
               $data['records'] = $this-&gt;db-&gt;where('id_Employee_lieve', $search_term)-&gt;get('cs_lieve', $confi['per_page'], $this-&gt;uri-&gt;segment(3))-&gt;result_array();
               $config['total_rows'] = sizeof($data['records']);
               // Use a model to retrieve the results.
               //     $data['rec'] = $this-&gt;employee-&gt;searchEmployee($search_term);
  
               // Pass the results to the view.
               $data['links'] = $this-&gt;pagination-&gt;create_links();
               $this-&gt;load-&gt;view('pages/HolidaysPosts', $data);
           }
           else $this-&gt;displayLieve();
  
       }
  
   }
  </code></pre>
  
  <p>the function that i called from the model is :</p>
  
  <pre><code>public function deleteEmployee($emloyeeName){
  //    $this-&gt;db-&gt;delete('cs_employee', array('name_Employee' =&gt; $emloyeeName));
      $this-&gt;db-&gt;where('name_Employee', $emloyeeName);
      $this-&gt;db-&gt;delete('cs_employee');
  }
  </code></pre>