我们如何从控制器发送数据到视图以及我们如何检测函数中的错误

How we send my data from controller to view and how we detect an error in my function.

public function ratings() { 

    $results['value']= $this->Home_registeration->get_ratings($_POST);

    $this->load->view ('display_search_result', $results); 

    Echo "";

    print_R ($results)
}

I have provide a sample code,how to send data from controller to views: You have to write the following code in controller function

$data['title']='ABC';
$data['page']='home';
$this->load->view('home',$data);

Now write the following code in home view file:

echo "The title is => ".$title;  //The title is => ABC
echo "The page is => ".$page;    //The page is => home

In Your case just open the view file namely (display_search_result.php) and write:

print_r($value);

First of all, you should not use $_POST in codeigniter, use $this->input->post() library instead. You can post data to views by passing the second argument in view and looping through array values, or by using class vars:

<?php
$data = [
    "id" => 234,
    "name" => "John Smith",
    "status" => 2
];

$this->data->id = 234;
$this->data->name = "John Smith";
$this->data->status = 2;

?>

(a) Then call your view :

<?php

    $this->load->view('viewname', $data);

?>

(b) OR :

<?php

    $this->load->view('viewname');

?>

(a) Then in your view file:

<p><?= $id ?></p>
<p><?= $name ?></p>
<p><?= $status ?></p>

(b) OR, if you are using $this->data->id etc.

<p><?= $this->data->id ?></p>
<p><?= $this->data->name ?></p>
<p><?= $this->data->status ?></p>

Hope it helps.

You need to check all requirement and all possibility failure before call your function to be proccess.

example:

public function ratings() { 
    $parameter = $this->input->post(null, TRUE); // null to get all index and TRUE to xss clean
    $results = array();
    if (empty($parameter))
    {
        $results['value'] = "Please input your parameter first";
    }
    else
    {
        // Asume parameter exist and safe enough to be proccess
        $results['value']= $this->Home_registeration->get_ratings($parameter);
        // you can also check result from get_ratings function
        // asume you will set rating 0 on empty return value from function
        if (empty($results['value'])) $results['value'] = 0;
    }


    $this->load->view ('display_search_result', $results); 

    echo "<pre>";
    print_r ($results);        
    echo "</pre>";

}