too long

I have fetched the record in my model against each user from database as follows:

public function counter_records() {

$table = 'usersearchs';
$this->db->select("domain, time");

$this->db->from($table);
$this->db->where("user_id", $this->session->userdata("user_id"));
$res = $this->db->get();
$num_of_records = $res->num_rows();

return $num_of_records;
}

Now I want to show these number of records into a view file for each user account, they have to know how many records they have.

Use this function for display all records against user_id in your Model:

public function userData()
{
    $results = array();
    $table = 'usersearchs';
    $this->db->select("domain, time");
    $this->db->from($table);
    $this->db->where("user_id",$this->session->userdata("user_id"));
    $query = $this->db->get();
    $num_of_records = $query->num_rows();
    if($num_of_records > 0){
        $results = $query->result_array();
    }   
    return $results;    
}

In Controller: call this function in your controller file like.

$this->load->model('model_yourmodel');
$data['records'] = $this->model_yourmodel->userData();

And pass this data in your view from controller as like:

$this->load_view("yourviewpath" , $data);

In HTML View File: Use loop for display this data like that:

<?
$total_records = count($records);
if($total_records <= 3){
echo (4-$total_records). " records remaining in your account";
}
else{
echo "You have reached the maximum record";
}

if($total_records > 0){  // $records that you have pass from your controller.
   foreach($records as $value){
   ?>
   // Your HTML Code 
   Domain <?=$value['domain']?> - Time <?=$value['time']?> <br/>
   // Your HTML Code
   <?
   }
}
else{
   // your HTML
   echo "No record found";
   // your HTML
}
?>

Result should be like that in HTML:

domain1 - time1 
domain2 - time2 
domain3 - time3 
domain4 - time4 
domain5 - time5