Welcome Guest, Not a member yet? Register   Sign In
Problems in sending code to views
#1

[eluser]Unknown[/eluser]
Can you please piont at my mistake. First of all I will write my code.

In my model I have:



Code:
class Left_model extends CI_Model
{
   public function __construct()
   {
      parent::__construct();
   }
  
   public function left2_narrow_model($cat)
   {
      $res = $this->db->where('narrow_cat', $cat)->count_all_results("NEW_materials");
      return $res;
   }
  
}



Controller:


Code:
class Left extends CI_Controller
{
   public function __construct()
   {
      parent::__construct();
   }
  
   public function left2_cont()
   {
      $this->load->model('attached/Left_model');
      $res['res'] = $this->Left_model->left2_narrow_model(1);
      $this->load->view('template/left2',$res);
      
      
      $this->load->model('attached/Left_model');
      $result['result'] = $this->Left_model->left2_narrow_model(2);
      $this->load->view('template/left2',$result);
   }
  
}



And view:

Code:
<p>&lt;?=$res;?&gt;</p>


<p>&lt;?=$result;?&gt;</p>



The problem is I have an error mistake:

Инициализирована ошибка PHP кода

Статус: Notice

Сообщение: Undefined variable: sql

Имя файла: template/left2.php

Номер строки: 2



Инициализирована ошибка PHP кода

Статус: Notice

Сообщение: Undefined variable: result

Имя файла: template/left2.php

Номер строки: 5



I can't understand where I made a mistake.




Theme © iAndrew 2016 - Forum software by © MyBB